BZOJ1695 : [Usaco2007 Demo]Walk the Talk

观察单词表可以发现:

对于长度为3的单词,前两个字母相同的单词不超过7个

对于长度为4的单词,前两个字母相同的单词不超过35个

 

于是首先$O(26*26*nm)$预处理出

s1[x][i][j]表示(i,j)右上角里面字母x的出现次数

s2[x][y][i][j]表示(i,j)右上角里面单词xy的出现次数

 

枚举一个点,计算长度为1的单词的出现次数

枚举两个点,计算长度为2,3,4的单词的出现次数

总时间复杂度为$O(kn^2m^2)$,k不超过43

 

#include<cstdio>
#include<string>
using namespace std;
const int N=35,M=2265,S=26;
int n,m,i,j,x,y,a[N][N],ans,v1[S],v2[S][S],s1[S][N][N],f[S][S][N][N],s2[S][S][N][N];
char ch[N];string d[M];
struct E{int x,y;E*nxt;}*g3[S][S],*g4[S][S],pool[M],*cur=pool,*p;
inline void add3(int a,int b,int x){p=cur++;p->x=x;p->nxt=g3[a][b];g3[a][b]=p;}
inline void add4(int a,int b,int x,int y){p=cur++;p->x=x;p->y=y;p->nxt=g4[a][b];g4[a][b]=p;}
int main(){
  d[0]="A";
  d[1]="AA";
  d[2]="AAA";
  d[3]="AAAA";
  d[4]="ABBE";
  d[5]="ABED";
  d[6]="ABET";
  d[7]="ABLE";
  d[8]="ABLY";
  d[9]="ABUT";
  d[10]="ACE";
  d[11]="ACES";
  d[12]="ACHE";
  d[13]="ACID";
  d[14]="ACME";
  d[15]="ACNE";
  d[16]="ACRE";
  d[17]="ACT";
  d[18]="AD";
  d[19]="ADD";
  d[20]="ADDS";
  d[21]="ADO";
  d[22]="ADS";
  d[23]="AFAR";
  d[24]="AFT";
  d[25]="AGAR";
  d[26]="AGE";
  d[27]="AGED";
  d[28]="AGER";
  d[29]="AGES";
  d[30]="AGO";
  d[31]="AGOG";
  d[32]="AGUE";
  d[33]="AH";
  d[34]="AID";
  d[35]="AIDE";
  d[36]="AIDS";
  d[37]="AIL";
  d[38]="AIM";
  d[39]="AIMS";
  d[40]="AIR";
  d[41]="AIRS";
  d[42]="AIRY";
  d[43]="AJAR";
  d[44]="AKIN";
  d[45]="ALAS";
  d[46]="ALBA";
  d[47]="ALE";
  d[48]="ALEE";
  d[49]="ALGA";
  d[50]="ALL";
  d[51]="ALLY";
  d[52]="ALMA";
  d[53]="ALMS";
  d[54]="ALOE";
  d[55]="ALSO";
  d[56]="ALUM";
  d[57]="AM";
  d[58]="AMEN";
  d[59]="AMID";
  d[60]="AMMO";
  d[61]="AMOK";
  d[62]="AMYL";
  d[63]="AN";
  d[64]="ANAL";
  d[65]="AND";
  d[66]="ANEW";
  d[67]="ANON";
  d[68]="ANT";
  d[69]="ANTE";
  d[70]="ANTI";
  d[71]="ANTS";
  d[72]="ANUS";
  d[73]="ANY";
  d[74]="APE";
  d[75]="APED";
  d[76]="APES";
  d[77]="APEX";
  d[78]="APSE";
  d[79]="APT";
  d[80]="AQUA";
  d[81]="ARC";
  d[82]="ARCH";
  d[83]="ARCS";
  d[84]="ARE";
  d[85]="AREA";
  d[86]="ARID";
  d[87]="ARK";
  d[88]="ARM";
  d[89]="ARMS";
  d[90]="ARMY";
  d[91]="ART";
  d[92]="ARTS";
  d[93]="AS";
  d[94]="ASH";
  d[95]="ASK";
  d[96]="ASKS";
  d[97]="ASP";
  d[98]="ASS";
  d[99]="AT";
  d[100]="ATE";
  d[101]="ATOM";
  d[102]="ATOP";
  d[103]="AUNT";
  d[104]="AURA";
  d[105]="AUTO";
  d[106]="AVER";
  d[107]="AVID";
  d[108]="AVOW";
  d[109]="AWAY";
  d[110]="AWE";
  d[111]="AWED";
  d[112]="AWL";
  d[113]="AWLS";
  d[114]="AWRY";
  d[115]="AX";
  d[116]="AXED";
  d[117]="AXER";
  d[118]="AXES";
  d[119]="AXIS";
  d[120]="AXLE";
  d[121]="AXON";
  d[122]="AYE";
  d[123]="AYES";
  d[124]="BABE";
  d[125]="BABY";
  d[126]="BACK";
  d[127]="BAD";
  d[128]="BADE";
  d[129]="BAG";
  d[130]="BAGS";
  d[131]="BAH";
  d[132]="BAIL";
  d[133]="BAIT";
  d[134]="BAKE";
  d[135]="BALD";
  d[136]="BALE";
  d[137]="BALK";
  d[138]="BALL";
  d[139]="BALM";
  d[140]="BAN";
  d[141]="BAND";
  d[142]="BANE";
  d[143]="BANG";
  d[144]="BANK";
  d[145]="BANS";
  d[146]="BAR";
  d[147]="BARB";
  d[148]="BARD";
  d[149]="BARE";
  d[150]="BARK";
  d[151]="BARN";
  d[152]="BARS";
  d[153]="BASE";
  d[154]="BASH";
  d[155]="BASK";
  d[156]="BASS";
  d[157]="BAT";
  d[158]="BATH";
  d[159]="BATS";
  d[160]="BAUD";
  d[161]="BAWL";
  d[162]="BAY";
  d[163]="BAYS";
  d[164]="BE";
  d[165]="BEAD";
  d[166]="BEAK";
  d[167]="BEAM";
  d[168]="BEAN";
  d[169]="BEAR";
  d[170]="BEAT";
  d[171]="BEAU";
  d[172]="BECK";
  d[173]="BED";
  d[174]="BEDS";
  d[175]="BEE";
  d[176]="BEEF";
  d[177]="BEEN";
  d[178]="BEEP";
  d[179]="BEER";
  d[180]="BEES";
  d[181]="BEET";
  d[182]="BEG";
  d[183]="BEGS";
  d[184]="BELL";
  d[185]="BELT";
  d[186]="BELY";
  d[187]="BEND";
  d[188]="BENT";
  d[189]="BEST";
  d[190]="BET";
  d[191]="BETA";
  d[192]="BETS";
  d[193]="BEVY";
  d[194]="BIAS";
  d[195]="BIB";
  d[196]="BIBS";
  d[197]="BID";
  d[198]="BIDE";
  d[199]="BIDS";
  d[200]="BIER";
  d[201]="BIG";
  d[202]="BIKE";
  d[203]="BILE";
  d[204]="BILK";
  d[205]="BILL";
  d[206]="BIN";
  d[207]="BIND";
  d[208]="BING";
  d[209]="BINS";
  d[210]="BIRD";
  d[211]="BIT";
  d[212]="BITE";
  d[213]="BITS";
  d[214]="BLAB";
  d[215]="BLED";
  d[216]="BLEW";
  d[217]="BLIP";
  d[218]="BLOB";
  d[219]="BLOC";
  d[220]="BLOT";
  d[221]="BLOW";
  d[222]="BLUE";
  d[223]="BLUR";
  d[224]="BOA";
  d[225]="BOAR";
  d[226]="BOAT";
  d[227]="BOB";
  d[228]="BOBS";
  d[229]="BODE";
  d[230]="BODY";
  d[231]="BOG";
  d[232]="BOGS";
  d[233]="BOIL";
  d[234]="BOLD";
  d[235]="BOLL";
  d[236]="BOLT";
  d[237]="BOMB";
  d[238]="BOND";
  d[239]="BONE";
  d[240]="BONG";
  d[241]="BONY";
  d[242]="BOO";
  d[243]="BOOB";
  d[244]="BOOK";
  d[245]="BOOM";
  d[246]="BOON";
  d[247]="BOOR";
  d[248]="BOOS";
  d[249]="BOOT";
  d[250]="BORE";
  d[251]="BORN";
  d[252]="BOSS";
  d[253]="BOTH";
  d[254]="BOUT";
  d[255]="BOW";
  d[256]="BOWL";
  d[257]="BOWS";
  d[258]="BOX";
  d[259]="BOY";
  d[260]="BOYS";
  d[261]="BRA";
  d[262]="BRAE";
  d[263]="BRAG";
  d[264]="BRAN";
  d[265]="BRAS";
  d[266]="BRAT";
  d[267]="BRAY";
  d[268]="BRED";
  d[269]="BREW";
  d[270]="BRIG";
  d[271]="BRIM";
  d[272]="BROW";
  d[273]="BUCK";
  d[274]="BUD";
  d[275]="BUDS";
  d[276]="BUFF";
  d[277]="BUG";
  d[278]="BUGS";
  d[279]="BULB";
  d[280]="BULK";
  d[281]="BULL";
  d[282]="BUM";
  d[283]="BUMP";
  d[284]="BUMS";
  d[285]="BUN";
  d[286]="BUNK";
  d[287]="BUNS";
  d[288]="BUNT";
  d[289]="BUOY";
  d[290]="BURL";
  d[291]="BURN";
  d[292]="BURP";
  d[293]="BURY";
  d[294]="BUS";
  d[295]="BUSH";
  d[296]="BUSS";
  d[297]="BUST";
  d[298]="BUSY";
  d[299]="BUT";
  d[300]="BUTT";
  d[301]="BUY";
  d[302]="BUYS";
  d[303]="BUZZ";
  d[304]="BY";
  d[305]="BYE";
  d[306]="BYTE";
  d[307]="CAB";
  d[308]="CABS";
  d[309]="CAFE";
  d[310]="CAGE";
  d[311]="CAKE";
  d[312]="CALF";
  d[313]="CALL";
  d[314]="CALM";
  d[315]="CAM";
  d[316]="CAME";
  d[317]="CAMP";
  d[318]="CAN";
  d[319]="CANE";
  d[320]="CANS";
  d[321]="CANT";
  d[322]="CAP";
  d[323]="CAPE";
  d[324]="CAPS";
  d[325]="CAR";
  d[326]="CARD";
  d[327]="CARE";
  d[328]="CARP";
  d[329]="CARS";
  d[330]="CART";
  d[331]="CASE";
  d[332]="CASH";
  d[333]="CASK";
  d[334]="CAST";
  d[335]="CAT";
  d[336]="CATS";
  d[337]="CAVE";
  d[338]="CAW";
  d[339]="CEDE";
  d[340]="CELL";
  d[341]="CENT";
  d[342]="CHAP";
  d[343]="CHAR";
  d[344]="CHAT";
  d[345]="CHEF";
  d[346]="CHEW";
  d[347]="CHIC";
  d[348]="CHIN";
  d[349]="CHIP";
  d[350]="CHIT";
  d[351]="CHOP";
  d[352]="CHUM";
  d[353]="CITE";
  d[354]="CITY";
  d[355]="CLAD";
  d[356]="CLAM";
  d[357]="CLAN";
  d[358]="CLAP";
  d[359]="CLAW";
  d[360]="CLAY";
  d[361]="CLIP";
  d[362]="CLOD";
  d[363]="CLOG";
  d[364]="CLOT";
  d[365]="CLUB";
  d[366]="CLUE";
  d[367]="COAL";
  d[368]="COAT";
  d[369]="COAX";
  d[370]="COCA";
  d[371]="COCK";
  d[372]="COCO";
  d[373]="COD";
  d[374]="CODE";
  d[375]="COED";
  d[376]="COG";
  d[377]="COGS";
  d[378]="COIL";
  d[379]="COIN";
  d[380]="COKE";
  d[381]="COLD";
  d[382]="COLT";
  d[383]="COMB";
  d[384]="COME";
  d[385]="CON";
  d[386]="CONE";
  d[387]="COO";
  d[388]="COOK";
  d[389]="COOL";
  d[390]="COON";
  d[391]="COOP";
  d[392]="COP";
  d[393]="COPE";
  d[394]="COPS";
  d[395]="COPY";
  d[396]="CORD";
  d[397]="CORE";
  d[398]="CORK";
  d[399]="CORN";
  d[400]="COST";
  d[401]="COSY";
  d[402]="COT";
  d[403]="COTS";
  d[404]="COVE";
  d[405]="COW";
  d[406]="COWL";
  d[407]="COWS";
  d[408]="COZY";
  d[409]="CRAB";
  d[410]="CRAG";
  d[411]="CRAM";
  d[412]="CREW";
  d[413]="CRIB";
  d[414]="CROP";
  d[415]="CROW";
  d[416]="CRUD";
  d[417]="CRUX";
  d[418]="CRY";
  d[419]="CUB";
  d[420]="CUBE";
  d[421]="CUBS";
  d[422]="CUE";
  d[423]="CUED";
  d[424]="CUES";
  d[425]="CUFF";
  d[426]="CULL";
  d[427]="CULT";
  d[428]="CUP";
  d[429]="CUPS";
  d[430]="CURB";
  d[431]="CURD";
  d[432]="CURE";
  d[433]="CURL";
  d[434]="CURS";
  d[435]="CURT";
  d[436]="CUSP";
  d[437]="CUT";
  d[438]="CUTE";
  d[439]="CUTS";
  d[440]="CYST";
  d[441]="CZAR";
  d[442]="DAD";
  d[443]="DADS";
  d[444]="DALE";
  d[445]="DAM";
  d[446]="DAME";
  d[447]="DAMN";
  d[448]="DAMP";
  d[449]="DAMS";
  d[450]="DARE";
  d[451]="DARK";
  d[452]="DARN";
  d[453]="DART";
  d[454]="DASH";
  d[455]="DATA";
  d[456]="DATE";
  d[457]="DAWN";
  d[458]="DAY";
  d[459]="DAYS";
  d[460]="DAZE";
  d[461]="DEAD";
  d[462]="DEAF";
  d[463]="DEAL";
  d[464]="DEAN";
  d[465]="DEAR";
  d[466]="DEBT";
  d[467]="DECK";
  d[468]="DEED";
  d[469]="DEEM";
  d[470]="DEEP";
  d[471]="DEER";
  d[472]="DEFY";
  d[473]="DELL";
  d[474]="DEMO";
  d[475]="DEN";
  d[476]="DENS";
  d[477]="DENT";
  d[478]="DENY";
  d[479]="DESK";
  d[480]="DEUS";
  d[481]="DEW";
  d[482]="DEWY";
  d[483]="DIAL";
  d[484]="DICE";
  d[485]="DID";
  d[486]="DIE";
  d[487]="DIED";
  d[488]="DIEM";
  d[489]="DIES";
  d[490]="DIET";
  d[491]="DIG";
  d[492]="DIGS";
  d[493]="DIKE";
  d[494]="DILL";
  d[495]="DIM";
  d[496]="DIME";
  d[497]="DIMS";
  d[498]="DIN";
  d[499]="DINE";
  d[500]="DING";
  d[501]="DINT";
  d[502]="DIP";
  d[503]="DIPS";
  d[504]="DIRE";
  d[505]="DIRT";
  d[506]="DISC";
  d[507]="DISH";
  d[508]="DISK";
  d[509]="DIVE";
  d[510]="DO";
  d[511]="DOCK";
  d[512]="DOE";
  d[513]="DOER";
  d[514]="DOES";
  d[515]="DOG";
  d[516]="DOGS";
  d[517]="DOLE";
  d[518]="DOLL";
  d[519]="DOME";
  d[520]="DON";
  d[521]="DONE";
  d[522]="DONS";
  d[523]="DOOM";
  d[524]="DOOR";
  d[525]="DOPE";
  d[526]="DOSE";
  d[527]="DOT";
  d[528]="DOTE";
  d[529]="DOTS";
  d[530]="DOVE";
  d[531]="DOWN";
  d[532]="DOZE";
  d[533]="DRAB";
  d[534]="DRAG";
  d[535]="DRAM";
  d[536]="DRAW";
  d[537]="DREW";
  d[538]="DRIP";
  d[539]="DROP";
  d[540]="DRUG";
  d[541]="DRUM";
  d[542]="DRY";
  d[543]="DUAL";
  d[544]="DUB";
  d[545]="DUBS";
  d[546]="DUCK";
  d[547]="DUCT";
  d[548]="DUD";
  d[549]="DUE";
  d[550]="DUEL";
  d[551]="DUES";
  d[552]="DUET";
  d[553]="DUG";
  d[554]="DUKE";
  d[555]="DULL";
  d[556]="DULY";
  d[557]="DUMB";
  d[558]="DUMP";
  d[559]="DUNE";
  d[560]="DUNG";
  d[561]="DUNK";
  d[562]="DUPE";
  d[563]="DUSK";
  d[564]="DUST";
  d[565]="DUTY";
  d[566]="DYAD";
  d[567]="DYE";
  d[568]="DYED";
  d[569]="DYER";
  d[570]="DYES";
  d[571]="DYNE";
  d[572]="EACH";
  d[573]="EAR";
  d[574]="EARL";
  d[575]="EARN";
  d[576]="EARS";
  d[577]="EASE";
  d[578]="EAST";
  d[579]="EASY";
  d[580]="EAT";
  d[581]="EATS";
  d[582]="EBB";
  d[583]="EBBS";
  d[584]="ECHO";
  d[585]="EDDY";
  d[586]="EDGE";
  d[587]="EDIT";
  d[588]="EEL";
  d[589]="EELS";
  d[590]="EGG";
  d[591]="EGGS";
  d[592]="EGO";
  d[593]="EGOS";
  d[594]="EKE";
  d[595]="EKED";
  d[596]="EKES";
  d[597]="ELF";
  d[598]="ELK";
  d[599]="ELKS";
  d[600]="ELM";
  d[601]="ELMS";
  d[602]="ELSE";
  d[603]="EM";
  d[604]="EMIT";
  d[605]="EN";
  d[606]="END";
  d[607]="ENDS";
  d[608]="ENVY";
  d[609]="EPIC";
  d[610]="ERA";
  d[611]="ERAS";
  d[612]="ERE";
  d[613]="ERG";
  d[614]="ERGO";
  d[615]="ERR";
  d[616]="ERRS";
  d[617]="ESPY";
  d[618]="ET";
  d[619]="ETCH";
  d[620]="EVEN";
  d[621]="EVER";
  d[622]="EVIL";
  d[623]="EWE";
  d[624]="EWES";
  d[625]="EX";
  d[626]="EXAM";
  d[627]="EXEC";
  d[628]="EXIT";
  d[629]="EYE";
  d[630]="EYED";
  d[631]="EYER";
  d[632]="EYES";
  d[633]="FACE";
  d[634]="FACT";
  d[635]="FADE";
  d[636]="FAG";
  d[637]="FAGS";
  d[638]="FAIL";
  d[639]="FAIN";
  d[640]="FAIR";
  d[641]="FAKE";
  d[642]="FALL";
  d[643]="FAME";
  d[644]="FAN";
  d[645]="FANG";
  d[646]="FANS";
  d[647]="FAR";
  d[648]="FARE";
  d[649]="FARM";
  d[650]="FAST";
  d[651]="FAT";
  d[652]="FATE";
  d[653]="FATS";
  d[654]="FAUN";
  d[655]="FAWN";
  d[656]="FAZE";
  d[657]="FEAR";
  d[658]="FEAT";
  d[659]="FED";
  d[660]="FEE";
  d[661]="FEED";
  d[662]="FEEL";
  d[663]="FEES";
  d[664]="FEET";
  d[665]="FELL";
  d[666]="FELT";
  d[667]="FEN";
  d[668]="FEND";
  d[669]="FERN";
  d[670]="FEUD";
  d[671]="FEW";
  d[672]="FIAT";
  d[673]="FIB";
  d[674]="FIEF";
  d[675]="FIFE";
  d[676]="FIG";
  d[677]="FIGS";
  d[678]="FILE";
  d[679]="FILL";
  d[680]="FILM";
  d[681]="FIN";
  d[682]="FIND";
  d[683]="FINE";
  d[684]="FINK";
  d[685]="FINS";
  d[686]="FIR";
  d[687]="FIRE";
  d[688]="FIRM";
  d[689]="FISH";
  d[690]="FIST";
  d[691]="FIT";
  d[692]="FITS";
  d[693]="FIVE";
  d[694]="FIX";
  d[695]="FLAG";
  d[696]="FLAK";
  d[697]="FLAM";
  d[698]="FLAP";
  d[699]="FLAT";
  d[700]="FLAW";
  d[701]="FLAX";
  d[702]="FLEA";
  d[703]="FLED";
  d[704]="FLEE";
  d[705]="FLEW";
  d[706]="FLEX";
  d[707]="FLIP";
  d[708]="FLIT";
  d[709]="FLOG";
  d[710]="FLOP";
  d[711]="FLOW";
  d[712]="FLU";
  d[713]="FLUE";
  d[714]="FLUX";
  d[715]="FLY";
  d[716]="FOAL";
  d[717]="FOAM";
  d[718]="FOB";
  d[719]="FOCI";
  d[720]="FOE";
  d[721]="FOES";
  d[722]="FOG";
  d[723]="FOGS";
  d[724]="FOGY";
  d[725]="FOIL";
  d[726]="FOLD";
  d[727]="FOLK";
  d[728]="FOND";
  d[729]="FONT";
  d[730]="FOOD";
  d[731]="FOOL";
  d[732]="FOOT";
  d[733]="FOR";
  d[734]="FORD";
  d[735]="FORE";
  d[736]="FORK";
  d[737]="FORM";
  d[738]="FORT";
  d[739]="FOUL";
  d[740]="FOUR";
  d[741]="FOWL";
  d[742]="FOX";
  d[743]="FRAY";
  d[744]="FREE";
  d[745]="FRET";
  d[746]="FRO";
  d[747]="FROG";
  d[748]="FROM";
  d[749]="FRY";
  d[750]="FUEL";
  d[751]="FULL";
  d[752]="FUME";
  d[753]="FUN";
  d[754]="FUND";
  d[755]="FUNK";
  d[756]="FUR";
  d[757]="FURS";
  d[758]="FURY";
  d[759]="FUSE";
  d[760]="FUSS";
  d[761]="FUZZ";
  d[762]="GAB";
  d[763]="GAD";
  d[764]="GAG";
  d[765]="GAGS";
  d[766]="GAIN";
  d[767]="GAIT";
  d[768]="GALE";
  d[769]="GALL";
  d[770]="GAME";
  d[771]="GANG";
  d[772]="GAP";
  d[773]="GAPE";
  d[774]="GAPS";
  d[775]="GARB";
  d[776]="GAS";
  d[777]="GASH";
  d[778]="GASP";
  d[779]="GATE";
  d[780]="GAVE";
  d[781]="GAWK";
  d[782]="GAY";
  d[783]="GAZE";
  d[784]="GEAR";
  d[785]="GEL";
  d[786]="GELD";
  d[787]="GELS";
  d[788]="GEM";
  d[789]="GEMS";
  d[790]="GENE";
  d[791]="GENT";
  d[792]="GERM";
  d[793]="GET";
  d[794]="GETS";
  d[795]="GIFT";
  d[796]="GIG";
  d[797]="GILD";
  d[798]="GILL";
  d[799]="GILT";
  d[800]="GIN";
  d[801]="GINS";
  d[802]="GIRD";
  d[803]="GIRL";
  d[804]="GIRT";
  d[805]="GIST";
  d[806]="GIVE";
  d[807]="GLAD";
  d[808]="GLEE";
  d[809]="GLEN";
  d[810]="GLOW";
  d[811]="GLUE";
  d[812]="GLUT";
  d[813]="GNAT";
  d[814]="GNAW";
  d[815]="GNU";
  d[816]="GO";
  d[817]="GOAD";
  d[818]="GOAL";
  d[819]="GOAT";
  d[820]="GOD";
  d[821]="GODS";
  d[822]="GOES";
  d[823]="GOLD";
  d[824]="GOLF";
  d[825]="GONE";
  d[826]="GONG";
  d[827]="GOOD";
  d[828]="GOOF";
  d[829]="GORE";
  d[830]="GORY";
  d[831]="GOSH";
  d[832]="GOT";
  d[833]="GOUT";
  d[834]="GOWN";
  d[835]="GRAB";
  d[836]="GRAD";
  d[837]="GRAM";
  d[838]="GRAY";
  d[839]="GREW";
  d[840]="GREY";
  d[841]="GRID";
  d[842]="GRIM";
  d[843]="GRIN";
  d[844]="GRIP";
  d[845]="GRIT";
  d[846]="GROW";
  d[847]="GRUB";
  d[848]="GULF";
  d[849]="GULL";
  d[850]="GULP";
  d[851]="GUM";
  d[852]="GUMS";
  d[853]="GUN";
  d[854]="GUNS";
  d[855]="GURU";
  d[856]="GUSH";
  d[857]="GUST";
  d[858]="GUT";
  d[859]="GUTS";
  d[860]="GUY";
  d[861]="GUYS";
  d[862]="GYRO";
  d[863]="HA";
  d[864]="HACK";
  d[865]="HAD";
  d[866]="HAG";
  d[867]="HAIL";
  d[868]="HAIR";
  d[869]="HALE";
  d[870]="HALF";
  d[871]="HALL";
  d[872]="HALT";
  d[873]="HAM";
  d[874]="HAMS";
  d[875]="HAND";
  d[876]="HANG";
  d[877]="HAP";
  d[878]="HARD";
  d[879]="HARE";
  d[880]="HARK";
  d[881]="HARM";
  d[882]="HARP";
  d[883]="HART";
  d[884]="HAS";
  d[885]="HASH";
  d[886]="HAT";
  d[887]="HATE";
  d[888]="HATS";
  d[889]="HAUL";
  d[890]="HAVE";
  d[891]="HAWK";
  d[892]="HAY";
  d[893]="HAZE";
  d[894]="HAZY";
  d[895]="HE";
  d[896]="HEAD";
  d[897]="HEAL";
  d[898]="HEAP";
  d[899]="HEAR";
  d[900]="HEAT";
  d[901]="HECK";
  d[902]="HEED";
  d[903]="HEEL";
  d[904]="HEIR";
  d[905]="HELD";
  d[906]="HELL";
  d[907]="HELM";
  d[908]="HELP";
  d[909]="HEM";
  d[910]="HEMP";
  d[911]="HEMS";
  d[912]="HEN";
  d[913]="HENS";
  d[914]="HER";
  d[915]="HERB";
  d[916]="HERD";
  d[917]="HERE";
  d[918]="HERO";
  d[919]="HERS";
  d[920]="HEW";
  d[921]="HEWS";
  d[922]="HEX";
  d[923]="HEY";
  d[924]="HI";
  d[925]="HICK";
  d[926]="HID";
  d[927]="HIDE";
  d[928]="HIGH";
  d[929]="HIKE";
  d[930]="HILL";
  d[931]="HILT";
  d[932]="HIM";
  d[933]="HIND";
  d[934]="HINT";
  d[935]="HIP";
  d[936]="HIPS";
  d[937]="HIRE";
  d[938]="HIS";
  d[939]="HISS";
  d[940]="HIT";
  d[941]="HITS";
  d[942]="HIVE";
  d[943]="HOAR";
  d[944]="HOE";
  d[945]="HOES";
  d[946]="HOG";
  d[947]="HOGS";
  d[948]="HOLD";
  d[949]="HOLE";
  d[950]="HOLY";
  d[951]="HOME";
  d[952]="HOMO";
  d[953]="HONE";
  d[954]="HOOD";
  d[955]="HOOF";
  d[956]="HOOK";
  d[957]="HOOP";
  d[958]="HOOT";
  d[959]="HOP";
  d[960]="HOPE";
  d[961]="HOPS";
  d[962]="HORN";
  d[963]="HOSE";
  d[964]="HOST";
  d[965]="HOT";
  d[966]="HOUR";
  d[967]="HOW";
  d[968]="HOWL";
  d[969]="HUB";
  d[970]="HUBS";
  d[971]="HUE";
  d[972]="HUES";
  d[973]="HUG";
  d[974]="HUGE";
  d[975]="HUH";
  d[976]="HULL";
  d[977]="HUM";
  d[978]="HUMP";
  d[979]="HUMS";
  d[980]="HUNG";
  d[981]="HUNK";
  d[982]="HUNT";
  d[983]="HURL";
  d[984]="HURT";
  d[985]="HUSH";
  d[986]="HUSK";
  d[987]="HUT";
  d[988]="HUTS";
  d[989]="HYMN";
  d[990]="IBEX";
  d[991]="IBID";
  d[992]="IBIS";
  d[993]="ICE";
  d[994]="ICED";
  d[995]="ICES";
  d[996]="ICON";
  d[997]="ICY";
  d[998]="IDEA";
  d[999]="IDEM";
  d[1000]="IDLE";
  d[1001]="IDLY";
  d[1002]="IDOL";
  d[1003]="IF";
  d[1004]="ILL";
  d[1005]="ILLS";
  d[1006]="ILLY";
  d[1007]="IMP";
  d[1008]="IMPS";
  d[1009]="IN";
  d[1010]="INCH";
  d[1011]="INK";
  d[1012]="INKS";
  d[1013]="INN";
  d[1014]="INNS";
  d[1015]="INTO";
  d[1016]="ION";
  d[1017]="IONS";
  d[1018]="IOTA";
  d[1019]="IRE";
  d[1020]="IRES";
  d[1021]="IRIS";
  d[1022]="IRK";
  d[1023]="IRKS";
  d[1024]="IRON";
  d[1025]="IS";
  d[1026]="ISLE";
  d[1027]="IT";
  d[1028]="ITCH";
  d[1029]="ITEM";
  d[1030]="ITS";
  d[1031]="IVY";
  d[1032]="JAB";
  d[1033]="JABS";
  d[1034]="JACK";
  d[1035]="JADE";
  d[1036]="JAIL";
  d[1037]="JAM";
  d[1038]="JAMS";
  d[1039]="JAR";
  d[1040]="JARS";
  d[1041]="JAW";
  d[1042]="JAWS";
  d[1043]="JAY";
  d[1044]="JAZZ";
  d[1045]="JEAN";
  d[1046]="JEEP";
  d[1047]="JEER";
  d[1048]="JERK";
  d[1049]="JEST";
  d[1050]="JET";
  d[1051]="JETS";
  d[1052]="JIG";
  d[1053]="JIGS";
  d[1054]="JOB";
  d[1055]="JOBS";
  d[1056]="JOG";
  d[1057]="JOGS";
  d[1058]="JOIN";
  d[1059]="JOKE";
  d[1060]="JOLT";
  d[1061]="JOT";
  d[1062]="JOTS";
  d[1063]="JOY";
  d[1064]="JOYS";
  d[1065]="JUDO";
  d[1066]="JUG";
  d[1067]="JUGS";
  d[1068]="JUMP";
  d[1069]="JUNK";
  d[1070]="JURE";
  d[1071]="JURY";
  d[1072]="JUST";
  d[1073]="JUT";
  d[1074]="KEEL";
  d[1075]="KEEN";
  d[1076]="KEEP";
  d[1077]="KEN";
  d[1078]="KEPT";
  d[1079]="KERN";
  d[1080]="KEY";
  d[1081]="KEYS";
  d[1082]="KICK";
  d[1083]="KID";
  d[1084]="KIDS";
  d[1085]="KILL";
  d[1086]="KIN";
  d[1087]="KIND";
  d[1088]="KING";
  d[1089]="KINK";
  d[1090]="KISS";
  d[1091]="KIT";
  d[1092]="KITE";
  d[1093]="KITS";
  d[1094]="KNEE";
  d[1095]="KNEW";
  d[1096]="KNIT";
  d[1097]="KNOB";
  d[1098]="KNOT";
  d[1099]="KNOW";
  d[1100]="KUDO";
  d[1101]="LAB";
  d[1102]="LABS";
  d[1103]="LACE";
  d[1104]="LACK";
  d[1105]="LACY";
  d[1106]="LAD";
  d[1107]="LADS";
  d[1108]="LADY";
  d[1109]="LAG";
  d[1110]="LAGS";
  d[1111]="LAID";
  d[1112]="LAIN";
  d[1113]="LAIR";
  d[1114]="LAKE";
  d[1115]="LAMB";
  d[1116]="LAME";
  d[1117]="LAMP";
  d[1118]="LAND";
  d[1119]="LANE";
  d[1120]="LAP";
  d[1121]="LAPS";
  d[1122]="LARD";
  d[1123]="LARK";
  d[1124]="LASH";
  d[1125]="LASS";
  d[1126]="LAST";
  d[1127]="LATE";
  d[1128]="LAVA";
  d[1129]="LAW";
  d[1130]="LAWN";
  d[1131]="LAWS";
  d[1132]="LAX";
  d[1133]="LAY";
  d[1134]="LAYS";
  d[1135]="LAZY";
  d[1136]="LEAD";
  d[1137]="LEAF";
  d[1138]="LEAK";
  d[1139]="LEAN";
  d[1140]="LEAP";
  d[1141]="LED";
  d[1142]="LEE";
  d[1143]="LEEK";
  d[1144]="LEER";
  d[1145]="LEES";
  d[1146]="LEFT";
  d[1147]="LEG";
  d[1148]="LEGS";
  d[1149]="LEND";
  d[1150]="LENS";
  d[1151]="LENT";
  d[1152]="LESS";
  d[1153]="LEST";
  d[1154]="LET";
  d[1155]="LETS";
  d[1156]="LEVY";
  d[1157]="LEWD";
  d[1158]="LIAR";
  d[1159]="LICE";
  d[1160]="LICK";
  d[1161]="LID";
  d[1162]="LIDS";
  d[1163]="LIE";
  d[1164]="LIED";
  d[1165]="LIEN";
  d[1166]="LIES";
  d[1167]="LIEU";
  d[1168]="LIFE";
  d[1169]="LIFT";
  d[1170]="LIKE";
  d[1171]="LILY";
  d[1172]="LIMB";
  d[1173]="LIME";
  d[1174]="LIMP";
  d[1175]="LINE";
  d[1176]="LINK";
  d[1177]="LINT";
  d[1178]="LION";
  d[1179]="LIP";
  d[1180]="LIPS";
  d[1181]="LISP";
  d[1182]="LIST";
  d[1183]="LIT";
  d[1184]="LIVE";
  d[1185]="LOAD";
  d[1186]="LOAF";
  d[1187]="LOAN";
  d[1188]="LOBE";
  d[1189]="LOCI";
  d[1190]="LOCK";
  d[1191]="LOFT";
  d[1192]="LOGO";
  d[1193]="LOGS";
  d[1194]="LOIN";
  d[1195]="LONE";
  d[1196]="LONG";
  d[1197]="LOOK";
  d[1198]="LOOM";
  d[1199]="LOON";
  d[1200]="LOOP";
  d[1201]="LOOT";
  d[1202]="LORD";
  d[1203]="LORE";
  d[1204]="LOSE";
  d[1205]="LOSS";
  d[1206]="LOST";
  d[1207]="LOT";
  d[1208]="LOTS";
  d[1209]="LOUD";
  d[1210]="LOUT";
  d[1211]="LOVE";
  d[1212]="LOW";
  d[1213]="LOWS";
  d[1214]="LUCK";
  d[1215]="LULL";
  d[1216]="LUMP";
  d[1217]="LUNG";
  d[1218]="LURE";
  d[1219]="LURK";
  d[1220]="LUSH";
  d[1221]="LUST";
  d[1222]="LUTE";
  d[1223]="LYNX";
  d[1224]="LYRE";
  d[1225]="MACE";
  d[1226]="MAD";
  d[1227]="MADE";
  d[1228]="MAID";
  d[1229]="MAIL";
  d[1230]="MAIM";
  d[1231]="MAIN";
  d[1232]="MAKE";
  d[1233]="MALE";
  d[1234]="MALL";
  d[1235]="MALT";
  d[1236]="MAMA";
  d[1237]="MAN";
  d[1238]="MANE";
  d[1239]="MANY";
  d[1240]="MAP";
  d[1241]="MAPS";
  d[1242]="MARE";
  d[1243]="MARK";
  d[1244]="MART";
  d[1245]="MASH";
  d[1246]="MASK";
  d[1247]="MASS";
  d[1248]="MAST";
  d[1249]="MAT";
  d[1250]="MATE";
  d[1251]="MATH";
  d[1252]="MATS";
  d[1253]="MAUL";
  d[1254]="MAZE";
  d[1255]="ME";
  d[1256]="MEAD";
  d[1257]="MEAL";
  d[1258]="MEAN";
  d[1259]="MEAT";
  d[1260]="MEEK";
  d[1261]="MEET";
  d[1262]="MELT";
  d[1263]="MEMO";
  d[1264]="MEN";
  d[1265]="MEND";
  d[1266]="MENS";
  d[1267]="MENU";
  d[1268]="MERE";
  d[1269]="MESH";
  d[1270]="MESS";
  d[1271]="MET";
  d[1272]="META";
  d[1273]="METE";
  d[1274]="METS";
  d[1275]="MEW";
  d[1276]="MEWS";
  d[1277]="MICA";
  d[1278]="MICE";
  d[1279]="MID";
  d[1280]="MIEN";
  d[1281]="MIKE";
  d[1282]="MILD";
  d[1283]="MILE";
  d[1284]="MILK";
  d[1285]="MILL";
  d[1286]="MIND";
  d[1287]="MINE";
  d[1288]="MINI";
  d[1289]="MINK";
  d[1290]="MINT";
  d[1291]="MIRE";
  d[1292]="MISS";
  d[1293]="MIST";
  d[1294]="MIX";
  d[1295]="MOAN";
  d[1296]="MOAT";
  d[1297]="MOB";
  d[1298]="MOBS";
  d[1299]="MOCK";
  d[1300]="MODE";
  d[1301]="MOLD";
  d[1302]="MOLE";
  d[1303]="MONK";
  d[1304]="MOO";
  d[1305]="MOOD";
  d[1306]="MOOT";
  d[1307]="MOP";
  d[1308]="MOPS";
  d[1309]="MORE";
  d[1310]="MORN";
  d[1311]="MOSS";
  d[1312]="MOST";
  d[1313]="MOTH";
  d[1314]="MOVE";
  d[1315]="MOW";
  d[1316]="MOWS";
  d[1317]="MU";
  d[1318]="MUCH";
  d[1319]="MUCK";
  d[1320]="MUD";
  d[1321]="MUFF";
  d[1322]="MUG";
  d[1323]="MUGS";
  d[1324]="MULE";
  d[1325]="MULL";
  d[1326]="MUNG";
  d[1327]="MUSE";
  d[1328]="MUSH";
  d[1329]="MUSK";
  d[1330]="MUST";
  d[1331]="MUTE";
  d[1332]="MUTT";
  d[1333]="MY";
  d[1334]="MYTH";
  d[1335]="NAB";
  d[1336]="NAG";
  d[1337]="NAGS";
  d[1338]="NAIL";
  d[1339]="NAME";
  d[1340]="NAP";
  d[1341]="NAPS";
  d[1342]="NARY";
  d[1343]="NAVY";
  d[1344]="NAY";
  d[1345]="NEAR";
  d[1346]="NEAT";
  d[1347]="NECK";
  d[1348]="NEED";
  d[1349]="NEON";
  d[1350]="NEST";
  d[1351]="NET";
  d[1352]="NETS";
  d[1353]="NEW";
  d[1354]="NEWT";
  d[1355]="NEXT";
  d[1356]="NICE";
  d[1357]="NICK";
  d[1358]="NIGH";
  d[1359]="NIL";
  d[1360]="NINE";
  d[1361]="NIP";
  d[1362]="NIPS";
  d[1363]="NO";
  d[1364]="NOD";
  d[1365]="NODE";
  d[1366]="NODS";
  d[1367]="NON";
  d[1368]="NONE";
  d[1369]="NOOK";
  d[1370]="NOON";
  d[1371]="NOR";
  d[1372]="NORM";
  d[1373]="NOSE";
  d[1374]="NOT";
  d[1375]="NOTE";
  d[1376]="NOUN";
  d[1377]="NOW";
  d[1378]="NU";
  d[1379]="NUDE";
  d[1380]="NULL";
  d[1381]="NUMB";
  d[1382]="NUN";
  d[1383]="NUNS";
  d[1384]="NUT";
  d[1385]="NUTS";
  d[1386]="OAF";
  d[1387]="OAK";
  d[1388]="OAKS";
  d[1389]="OAR";
  d[1390]="OARS";
  d[1391]="OAT";
  d[1392]="OATH";
  d[1393]="OATS";
  d[1394]="OBEY";
  d[1395]="OBOE";
  d[1396]="ODD";
  d[1397]="ODDS";
  d[1398]="ODE";
  d[1399]="ODES";
  d[1400]="ODOR";
  d[1401]="OF";
  d[1402]="OFF";
  d[1403]="OFFS";
  d[1404]="OFT";
  d[1405]="OH";
  d[1406]="OHM";
  d[1407]="OIL";
  d[1408]="OILS";
  d[1409]="OILY";
  d[1410]="OKAY";
  d[1411]="OLD";
  d[1412]="OLDY";
  d[1413]="OMEN";
  d[1414]="OMIT";
  d[1415]="ON";
  d[1416]="ONCE";
  d[1417]="ONE";
  d[1418]="ONES";
  d[1419]="ONLY";
  d[1420]="ONTO";
  d[1421]="ONUS";
  d[1422]="ONYX";
  d[1423]="OOZE";
  d[1424]="OPAL";
  d[1425]="OPEN";
  d[1426]="OPT";
  d[1427]="OPTS";
  d[1428]="OPUS";
  d[1429]="OR";
  d[1430]="ORAL";
  d[1431]="ORB";
  d[1432]="ORE";
  d[1433]="ORES";
  d[1434]="ORGY";
  d[1435]="OUCH";
  d[1436]="OUR";
  d[1437]="OURS";
  d[1438]="OUST";
  d[1439]="OUT";
  d[1440]="OUTS";
  d[1441]="OVAL";
  d[1442]="OVEN";
  d[1443]="OVER";
  d[1444]="OWE";
  d[1445]="OWED";
  d[1446]="OWES";
  d[1447]="OWL";
  d[1448]="OWLS";
  d[1449]="OWN";
  d[1450]="OWNS";
  d[1451]="OX";
  d[1452]="OXEN";
  d[1453]="PACE";
  d[1454]="PACK";
  d[1455]="PACT";
  d[1456]="PAD";
  d[1457]="PADS";
  d[1458]="PAGE";
  d[1459]="PAID";
  d[1460]="PAIL";
  d[1461]="PAIN";
  d[1462]="PAIR";
  d[1463]="PAL";
  d[1464]="PALE";
  d[1465]="PALL";
  d[1466]="PALM";
  d[1467]="PALS";
  d[1468]="PAN";
  d[1469]="PANE";
  d[1470]="PANG";
  d[1471]="PANS";
  d[1472]="PANT";
  d[1473]="PAPA";
  d[1474]="PAR";
  d[1475]="PARE";
  d[1476]="PARK";
  d[1477]="PARS";
  d[1478]="PART";
  d[1479]="PASS";
  d[1480]="PAST";
  d[1481]="PAT";
  d[1482]="PATE";
  d[1483]="PATH";
  d[1484]="PATS";
  d[1485]="PAVE";
  d[1486]="PAW";
  d[1487]="PAWN";
  d[1488]="PAWS";
  d[1489]="PAY";
  d[1490]="PAYS";
  d[1491]="PEA";
  d[1492]="PEAK";
  d[1493]="PEAL";
  d[1494]="PEAR";
  d[1495]="PEAS";
  d[1496]="PEAT";
  d[1497]="PECK";
  d[1498]="PEEK";
  d[1499]="PEEL";
  d[1500]="PEEP";
  d[1501]="PEER";
  d[1502]="PEG";
  d[1503]="PEGS";
  d[1504]="PELT";
  d[1505]="PEN";
  d[1506]="PEND";
  d[1507]="PENS";
  d[1508]="PENT";
  d[1509]="PEP";
  d[1510]="PER";
  d[1511]="PERK";
  d[1512]="PEST";
  d[1513]="PET";
  d[1514]="PETS";
  d[1515]="PEW";
  d[1516]="PEWS";
  d[1517]="PHI";
  d[1518]="PI";
  d[1519]="PICA";
  d[1520]="PICK";
  d[1521]="PIE";
  d[1522]="PIER";
  d[1523]="PIES";
  d[1524]="PIG";
  d[1525]="PIGS";
  d[1526]="PIKE";
  d[1527]="PILE";
  d[1528]="PILL";
  d[1529]="PIMP";
  d[1530]="PIN";
  d[1531]="PINE";
  d[1532]="PING";
  d[1533]="PINK";
  d[1534]="PINS";
  d[1535]="PINT";
  d[1536]="PION";
  d[1537]="PIP";
  d[1538]="PIPE";
  d[1539]="PISS";
  d[1540]="PIT";
  d[1541]="PITH";
  d[1542]="PITS";
  d[1543]="PITY";
  d[1544]="PLAN";
  d[1545]="PLAY";
  d[1546]="PLEA";
  d[1547]="PLOD";
  d[1548]="PLOT";
  d[1549]="PLOW";
  d[1550]="PLOY";
  d[1551]="PLUG";
  d[1552]="PLUM";
  d[1553]="PLUS";
  d[1554]="PLY";
  d[1555]="POD";
  d[1556]="PODS";
  d[1557]="POEM";
  d[1558]="POET";
  d[1559]="POGO";
  d[1560]="POKE";
  d[1561]="POLE";
  d[1562]="POLL";
  d[1563]="POLO";
  d[1564]="POMP";
  d[1565]="POND";
  d[1566]="PONG";
  d[1567]="PONY";
  d[1568]="POOL";
  d[1569]="POOR";
  d[1570]="POP";
  d[1571]="POPS";
  d[1572]="PORE";
  d[1573]="PORK";
  d[1574]="PORT";
  d[1575]="POSE";
  d[1576]="POSH";
  d[1577]="POST";
  d[1578]="POT";
  d[1579]="POTS";
  d[1580]="POUR";
  d[1581]="POUT";
  d[1582]="POX";
  d[1583]="PRAY";
  d[1584]="PREP";
  d[1585]="PREY";
  d[1586]="PRIM";
  d[1587]="PRO";
  d[1588]="PROD";
  d[1589]="PROP";
  d[1590]="PROS";
  d[1591]="PROW";
  d[1592]="PRY";
  d[1593]="PUB";
  d[1594]="PUBS";
  d[1595]="PUFF";
  d[1596]="PUKE";
  d[1597]="PULL";
  d[1598]="PULP";
  d[1599]="PUMA";
  d[1600]="PUMP";
  d[1601]="PUN";
  d[1602]="PUNS";
  d[1603]="PUNT";
  d[1604]="PUNY";
  d[1605]="PUP";
  d[1606]="PUPA";
  d[1607]="PUPS";
  d[1608]="PURE";
  d[1609]="PURR";
  d[1610]="PUS";
  d[1611]="PUSH";
  d[1612]="PUSS";
  d[1613]="PUT";
  d[1614]="PUTS";
  d[1615]="PUTT";
  d[1616]="PYRE";
  d[1617]="QUA";
  d[1618]="QUAD";
  d[1619]="QUAY";
  d[1620]="QUIP";
  d[1621]="QUIT";
  d[1622]="QUIZ";
  d[1623]="QUO";
  d[1624]="RACE";
  d[1625]="RACK";
  d[1626]="RAFT";
  d[1627]="RAG";
  d[1628]="RAGE";
  d[1629]="RAGS";
  d[1630]="RAID";
  d[1631]="RAIL";
  d[1632]="RAIN";
  d[1633]="RAKE";
  d[1634]="RAM";
  d[1635]="RAMP";
  d[1636]="RAMS";
  d[1637]="RAN";
  d[1638]="RANG";
  d[1639]="RANK";
  d[1640]="RANT";
  d[1641]="RAP";
  d[1642]="RAPE";
  d[1643]="RAPS";
  d[1644]="RAPT";
  d[1645]="RARE";
  d[1646]="RASH";
  d[1647]="RASP";
  d[1648]="RAT";
  d[1649]="RATE";
  d[1650]="RATS";
  d[1651]="RAVE";
  d[1652]="RAW";
  d[1653]="RAY";
  d[1654]="RAYS";
  d[1655]="RAZE";
  d[1656]="RE";
  d[1657]="READ";
  d[1658]="REAL";
  d[1659]="REAM";
  d[1660]="REAP";
  d[1661]="REAR";
  d[1662]="RED";
  d[1663]="REDO";
  d[1664]="REDS";
  d[1665]="REED";
  d[1666]="REEF";
  d[1667]="REEL";
  d[1668]="REIN";
  d[1669]="RELY";
  d[1670]="REND";
  d[1671]="RENT";
  d[1672]="REST";
  d[1673]="RHO";
  d[1674]="RIB";
  d[1675]="RIBS";
  d[1676]="RICE";
  d[1677]="RICH";
  d[1678]="RID";
  d[1679]="RIDE";
  d[1680]="RIDS";
  d[1681]="RIFT";
  d[1682]="RIG";
  d[1683]="RIGS";
  d[1684]="RILL";
  d[1685]="RIM";
  d[1686]="RIME";
  d[1687]="RIMS";
  d[1688]="RIND";
  d[1689]="RING";
  d[1690]="RINK";
  d[1691]="RIOT";
  d[1692]="RIP";
  d[1693]="RIPE";
  d[1694]="RIPS";
  d[1695]="RISE";
  d[1696]="RISK";
  d[1697]="RITE";
  d[1698]="ROAD";
  d[1699]="ROAM";
  d[1700]="ROAR";
  d[1701]="ROB";
  d[1702]="ROBE";
  d[1703]="ROBS";
  d[1704]="ROCK";
  d[1705]="ROD";
  d[1706]="RODE";
  d[1707]="RODS";
  d[1708]="ROE";
  d[1709]="ROLE";
  d[1710]="ROLL";
  d[1711]="ROMP";
  d[1712]="ROOF";
  d[1713]="ROOK";
  d[1714]="ROOM";
  d[1715]="ROOT";
  d[1716]="ROPE";
  d[1717]="ROSY";
  d[1718]="ROT";
  d[1719]="ROTS";
  d[1720]="ROUT";
  d[1721]="ROVE";
  d[1722]="ROW";
  d[1723]="ROWS";
  d[1724]="RUB";
  d[1725]="RUBS";
  d[1726]="RUBY";
  d[1727]="RUDE";
  d[1728]="RUE";
  d[1729]="RUG";
  d[1730]="RUGS";
  d[1731]="RUIN";
  d[1732]="RULE";
  d[1733]="RUM";
  d[1734]="RUMP";
  d[1735]="RUN";
  d[1736]="RUNG";
  d[1737]="RUNS";
  d[1738]="RUNT";
  d[1739]="RUSH";
  d[1740]="RUST";
  d[1741]="RUT";
  d[1742]="RUTS";
  d[1743]="RYE";
  d[1744]="SACK";
  d[1745]="SAD";
  d[1746]="SAFE";
  d[1747]="SAG";
  d[1748]="SAGA";
  d[1749]="SAGE";
  d[1750]="SAGS";
  d[1751]="SAID";
  d[1752]="SAIL";
  d[1753]="SAKE";
  d[1754]="SALE";
  d[1755]="SALT";
  d[1756]="SAME";
  d[1757]="SAND";
  d[1758]="SANE";
  d[1759]="SANG";
  d[1760]="SANK";
  d[1761]="SAP";
  d[1762]="SAPS";
  d[1763]="SARI";
  d[1764]="SASH";
  d[1765]="SAT";
  d[1766]="SATE";
  d[1767]="SAVE";
  d[1768]="SAW";
  d[1769]="SAWS";
  d[1770]="SAX";
  d[1771]="SAY";
  d[1772]="SAYS";
  d[1773]="SCAB";
  d[1774]="SCAN";
  d[1775]="SCAR";
  d[1776]="SCOW";
  d[1777]="SCUD";
  d[1778]="SEA";
  d[1779]="SEAL";
  d[1780]="SEAM";
  d[1781]="SEAR";
  d[1782]="SEAS";
  d[1783]="SEAT";
  d[1784]="SECT";
  d[1785]="SEE";
  d[1786]="SEED";
  d[1787]="SEEK";
  d[1788]="SEEM";
  d[1789]="SEEN";
  d[1790]="SEEP";
  d[1791]="SEER";
  d[1792]="SEES";
  d[1793]="SELF";
  d[1794]="SELL";
  d[1795]="SEMI";
  d[1796]="SEND";
  d[1797]="SENT";
  d[1798]="SEPT";
  d[1799]="SERF";
  d[1800]="SET";
  d[1801]="SETS";
  d[1802]="SEW";
  d[1803]="SEWS";
  d[1804]="SEX";
  d[1805]="SEXY";
  d[1806]="SHAM";
  d[1807]="SHE";
  d[1808]="SHED";
  d[1809]="SHIN";
  d[1810]="SHIP";
  d[1811]="SHIT";
  d[1812]="SHOD";
  d[1813]="SHOE";
  d[1814]="SHOP";
  d[1815]="SHOT";
  d[1816]="SHOW";
  d[1817]="SHUN";
  d[1818]="SHUT";
  d[1819]="SHY";
  d[1820]="SICK";
  d[1821]="SIDE";
  d[1822]="SIFT";
  d[1823]="SIGH";
  d[1824]="SIGN";
  d[1825]="SILK";
  d[1826]="SILL";
  d[1827]="SILO";
  d[1828]="SILT";
  d[1829]="SINE";
  d[1830]="SING";
  d[1831]="SINK";
  d[1832]="SINS";
  d[1833]="SIP";
  d[1834]="SIPS";
  d[1835]="SIR";
  d[1836]="SIRE";
  d[1837]="SIRS";
  d[1838]="SIT";
  d[1839]="SITE";
  d[1840]="SITS";
  d[1841]="SITU";
  d[1842]="SIX";
  d[1843]="SIZE";
  d[1844]="SKEW";
  d[1845]="SKI";
  d[1846]="SKID";
  d[1847]="SKIM";
  d[1848]="SKIN";
  d[1849]="SKIP";
  d[1850]="SKIS";
  d[1851]="SKIT";
  d[1852]="SKY";
  d[1853]="SLAB";
  d[1854]="SLAM";
  d[1855]="SLAP";
  d[1856]="SLAT";
  d[1857]="SLAY";
  d[1858]="SLED";
  d[1859]="SLEW";
  d[1860]="SLID";
  d[1861]="SLIM";
  d[1862]="SLIP";
  d[1863]="SLIT";
  d[1864]="SLOB";
  d[1865]="SLOP";
  d[1866]="SLOT";
  d[1867]="SLOW";
  d[1868]="SLUG";
  d[1869]="SLUM";
  d[1870]="SLUR";
  d[1871]="SLY";
  d[1872]="SMOG";
  d[1873]="SMUG";
  d[1874]="SMUT";
  d[1875]="SNAG";
  d[1876]="SNAP";
  d[1877]="SNIP";
  d[1878]="SNOB";
  d[1879]="SNOW";
  d[1880]="SNUB";
  d[1881]="SNUG";
  d[1882]="SO";
  d[1883]="SOAK";
  d[1884]="SOAP";
  d[1885]="SOAR";
  d[1886]="SOB";
  d[1887]="SOBS";
  d[1888]="SOCK";
  d[1889]="SOD";
  d[1890]="SODA";
  d[1891]="SODS";
  d[1892]="SOFA";
  d[1893]="SOFT";
  d[1894]="SOIL";
  d[1895]="SOLD";
  d[1896]="SOLE";
  d[1897]="SOLO";
  d[1898]="SOME";
  d[1899]="SON";
  d[1900]="SONG";
  d[1901]="SONS";
  d[1902]="SOON";
  d[1903]="SOOT";
  d[1904]="SORE";
  d[1905]="SORT";
  d[1906]="SOUL";
  d[1907]="SOUP";
  d[1908]="SOUR";
  d[1909]="SOW";
  d[1910]="SOWN";
  d[1911]="SOY";
  d[1912]="SOYA";
  d[1913]="SPA";
  d[1914]="SPAN";
  d[1915]="SPAT";
  d[1916]="SPEC";
  d[1917]="SPED";
  d[1918]="SPIN";
  d[1919]="SPIT";
  d[1920]="SPOT";
  d[1921]="SPUN";
  d[1922]="SPUR";
  d[1923]="SPY";
  d[1924]="STAB";
  d[1925]="STAG";
  d[1926]="STAR";
  d[1927]="STAY";
  d[1928]="STEM";
  d[1929]="STEP";
  d[1930]="STEW";
  d[1931]="STIR";
  d[1932]="STOP";
  d[1933]="STOW";
  d[1934]="STUB";
  d[1935]="STUD";
  d[1936]="STUN";
  d[1937]="SUB";
  d[1938]="SUBS";
  d[1939]="SUCH";
  d[1940]="SUCK";
  d[1941]="SUDS";
  d[1942]="SUE";
  d[1943]="SUED";
  d[1944]="SUES";
  d[1945]="SUIT";
  d[1946]="SULK";
  d[1947]="SUM";
  d[1948]="SUMS";
  d[1949]="SUN";
  d[1950]="SUNG";
  d[1951]="SUNK";
  d[1952]="SUNS";
  d[1953]="SURE";
  d[1954]="SURF";
  d[1955]="SWAB";
  d[1956]="SWAM";
  d[1957]="SWAN";
  d[1958]="SWAP";
  d[1959]="SWAT";
  d[1960]="SWAY";
  d[1961]="SWIM";
  d[1962]="SWUM";
  d[1963]="TAB";
  d[1964]="TABS";
  d[1965]="TACK";
  d[1966]="TACT";
  d[1967]="TAG";
  d[1968]="TAGS";
  d[1969]="TAIL";
  d[1970]="TAKE";
  d[1971]="TALE";
  d[1972]="TALK";
  d[1973]="TALL";
  d[1974]="TAME";
  d[1975]="TAN";
  d[1976]="TANG";
  d[1977]="TANK";
  d[1978]="TAP";
  d[1979]="TAPE";
  d[1980]="TAPS";
  d[1981]="TAR";
  d[1982]="TART";
  d[1983]="TASK";
  d[1984]="TAU";
  d[1985]="TAUT";
  d[1986]="TAX";
  d[1987]="TAXI";
  d[1988]="TEA";
  d[1989]="TEAM";
  d[1990]="TEAR";
  d[1991]="TEAS";
  d[1992]="TEEM";
  d[1993]="TEEN";
  d[1994]="TELL";
  d[1995]="TEN";
  d[1996]="TEND";
  d[1997]="TENS";
  d[1998]="TENT";
  d[1999]="TERM";
  d[2000]="TEST";
  d[2001]="TEXT";
  d[2002]="THAN";
  d[2003]="THAT";
  d[2004]="THAW";
  d[2005]="THE";
  d[2006]="THEM";
  d[2007]="THEN";
  d[2008]="THEY";
  d[2009]="THIN";
  d[2010]="THIS";
  d[2011]="THUD";
  d[2012]="THUG";
  d[2013]="THUS";
  d[2014]="TICK";
  d[2015]="TIDE";
  d[2016]="TIDY";
  d[2017]="TIE";
  d[2018]="TIED";
  d[2019]="TIER";
  d[2020]="TIES";
  d[2021]="TILE";
  d[2022]="TILL";
  d[2023]="TILT";
  d[2024]="TIME";
  d[2025]="TIN";
  d[2026]="TINS";
  d[2027]="TINT";
  d[2028]="TINY";
  d[2029]="TIP";
  d[2030]="TIPS";
  d[2031]="TIRE";
  d[2032]="TIT";
  d[2033]="TITS";
  d[2034]="TO";
  d[2035]="TOAD";
  d[2036]="TOE";
  d[2037]="TOES";
  d[2038]="TOIL";
  d[2039]="TOLD";
  d[2040]="TOLL";
  d[2041]="TOMB";
  d[2042]="TON";
  d[2043]="TONE";
  d[2044]="TONS";
  d[2045]="TOO";
  d[2046]="TOOK";
  d[2047]="TOOL";
  d[2048]="TOP";
  d[2049]="TOPS";
  d[2050]="TORE";
  d[2051]="TORN";
  d[2052]="TOSS";
  d[2053]="TOUR";
  d[2054]="TOW";
  d[2055]="TOWN";
  d[2056]="TOY";
  d[2057]="TOYS";
  d[2058]="TRAP";
  d[2059]="TRAY";
  d[2060]="TREE";
  d[2061]="TREK";
  d[2062]="TRIM";
  d[2063]="TRIO";
  d[2064]="TRIP";
  d[2065]="TROD";
  d[2066]="TROT";
  d[2067]="TRUE";
  d[2068]="TRY";
  d[2069]="TUB";
  d[2070]="TUBE";
  d[2071]="TUBS";
  d[2072]="TUCK";
  d[2073]="TUFT";
  d[2074]="TUG";
  d[2075]="TUGS";
  d[2076]="TUNE";
  d[2077]="TURF";
  d[2078]="TURN";
  d[2079]="TWAS";
  d[2080]="TWIG";
  d[2081]="TWIN";
  d[2082]="TWO";
  d[2083]="TWOS";
  d[2084]="TYPE";
  d[2085]="TYPO";
  d[2086]="UGH";
  d[2087]="UGLY";
  d[2088]="UNDO";
  d[2089]="UNIT";
  d[2090]="UNTO";
  d[2091]="UP";
  d[2092]="UPON";
  d[2093]="URGE";
  d[2094]="URN";
  d[2095]="URNS";
  d[2096]="US";
  d[2097]="USE";
  d[2098]="USED";
  d[2099]="USER";
  d[2100]="USES";
  d[2101]="VAIN";
  d[2102]="VALE";
  d[2103]="VAN";
  d[2104]="VANE";
  d[2105]="VANS";
  d[2106]="VARY";
  d[2107]="VASE";
  d[2108]="VAST";
  d[2109]="VAT";
  d[2110]="VATS";
  d[2111]="VEAL";
  d[2112]="VEER";
  d[2113]="VEIL";
  d[2114]="VEIN";
  d[2115]="VENT";
  d[2116]="VERB";
  d[2117]="VERY";
  d[2118]="VEST";
  d[2119]="VETO";
  d[2120]="VEX";
  d[2121]="VIA";
  d[2122]="VIAL";
  d[2123]="VICE";
  d[2124]="VIE";
  d[2125]="VIED";
  d[2126]="VIER";
  d[2127]="VIES";
  d[2128]="VIEW";
  d[2129]="VILE";
  d[2130]="VINE";
  d[2131]="VISA";
  d[2132]="VITA";
  d[2133]="VOID";
  d[2134]="VOLT";
  d[2135]="VOTE";
  d[2136]="VOW";
  d[2137]="VOWS";
  d[2138]="WADE";
  d[2139]="WAFT";
  d[2140]="WAG";
  d[2141]="WAGE";
  d[2142]="WAGS";
  d[2143]="WAIL";
  d[2144]="WAIT";
  d[2145]="WAKE";
  d[2146]="WALK";
  d[2147]="WALL";
  d[2148]="WAN";
  d[2149]="WAND";
  d[2150]="WANE";
  d[2151]="WANT";
  d[2152]="WAR";
  d[2153]="WARD";
  d[2154]="WARE";
  d[2155]="WARM";
  d[2156]="WARN";
  d[2157]="WARP";
  d[2158]="WARS";
  d[2159]="WART";
  d[2160]="WARY";
  d[2161]="WAS";
  d[2162]="WASH";
  d[2163]="WASP";
  d[2164]="WAVE";
  d[2165]="WAX";
  d[2166]="WAXY";
  d[2167]="WAY";
  d[2168]="WAYS";
  d[2169]="WE";
  d[2170]="WEAK";
  d[2171]="WEAN";
  d[2172]="WEAR";
  d[2173]="WEB";
  d[2174]="WEBS";
  d[2175]="WEDS";
  d[2176]="WEE";
  d[2177]="WEED";
  d[2178]="WEEK";
  d[2179]="WEEP";
  d[2180]="WELD";
  d[2181]="WELL";
  d[2182]="WENT";
  d[2183]="WEPT";
  d[2184]="WERE";
  d[2185]="WEST";
  d[2186]="WET";
  d[2187]="WETS";
  d[2188]="WHAT";
  d[2189]="WHEN";
  d[2190]="WHIM";
  d[2191]="WHIP";
  d[2192]="WHIT";
  d[2193]="WHIZ";
  d[2194]="WHO";
  d[2195]="WHOM";
  d[2196]="WHY";
  d[2197]="WICK";
  d[2198]="WIDE";
  d[2199]="WIFE";
  d[2200]="WIG";
  d[2201]="WIGS";
  d[2202]="WILD";
  d[2203]="WILE";
  d[2204]="WILL";
  d[2205]="WILT";
  d[2206]="WILY";
  d[2207]="WIN";
  d[2208]="WIND";
  d[2209]="WINE";
  d[2210]="WING";
  d[2211]="WINK";
  d[2212]="WINS";
  d[2213]="WIPE";
  d[2214]="WIRE";
  d[2215]="WIRY";
  d[2216]="WISE";
  d[2217]="WISH";
  d[2218]="WISP";
  d[2219]="WIT";
  d[2220]="WITH";
  d[2221]="WITS";
  d[2222]="WOE";
  d[2223]="WOKE";
  d[2224]="WOLF";
  d[2225]="WOMB";
  d[2226]="WON";
  d[2227]="WONT";
  d[2228]="WOO";
  d[2229]="WOOD";
  d[2230]="WOOF";
  d[2231]="WOOL";
  d[2232]="WOOS";
  d[2233]="WORD";
  d[2234]="WORE";
  d[2235]="WORK";
  d[2236]="WORM";
  d[2237]="WORN";
  d[2238]="WOVE";
  d[2239]="WRAP";
  d[2240]="WREN";
  d[2241]="WRIT";
  d[2242]="YANK";
  d[2243]="YARD";
  d[2244]="YARN";
  d[2245]="YAWN";
  d[2246]="YEA";
  d[2247]="YEAR";
  d[2248]="YEAS";
  d[2249]="YELL";
  d[2250]="YELP";
  d[2251]="YES";
  d[2252]="YET";
  d[2253]="YOKE";
  d[2254]="YON";
  d[2255]="YOU";
  d[2256]="YOUR";
  d[2257]="ZEAL";
  d[2258]="ZERO";
  d[2259]="ZEST";
  d[2260]="ZINC";
  d[2261]="ZONE";
  d[2262]="ZOO";
  d[2263]="ZOOM";
  d[2264]="ZOOS";
  for(i=0;i<M;i++){
    j=d[i].size();
    for(x=0;x<j;x++)d[i][x]-='A';
    if(j==1)v1[d[i][0]]=1;
    if(j==2)v2[d[i][0]][d[i][1]]=1;
    if(j==3)add3(d[i][0],d[i][1],d[i][2]);
    if(j==4)add4(d[i][0],d[i][1],d[i][2],d[i][3]);
  }
  for(scanf("%d%d",&n,&m),i=1;i<=n;i++)for(scanf("%s",ch+1),j=1;j<=m;j++)a[i][j]=ch[j]-'A';
  for(x=0;x<S;x++)for(i=1;i<=n;i++)for(j=m;j;j--){
    s1[x][i][j]=s1[x][i-1][j]+s1[x][i][j+1]-s1[x][i-1][j+1]+(a[i][j]==x);
    f[a[i][j]][x][i][j]=s1[x][i][j]-(a[i][j]==x);
  }
  for(x=0;x<S;x++)for(y=0;y<S;y++)for(i=1;i<=n;i++)for(j=m;j;j--)s2[x][y][i][j]=s2[x][y][i-1][j]+s2[x][y][i][j+1]-s2[x][y][i-1][j+1]+f[x][y][i][j];
  for(i=1;i<=n;i++)for(j=1;j<=m;j++){
    if(v1[a[i][j]])ans++;
    for(x=i;x;x--)for(y=x==i?j+1:j;y<=m;y++){
      if(v2[a[i][j]][a[x][y]])ans++;
      for(p=g3[a[i][j]][a[x][y]];p;p=p->nxt)ans+=s1[p->x][x][y]-(a[x][y]==p->x);
      for(p=g4[a[i][j]][a[x][y]];p;p=p->nxt)ans+=s2[p->x][p->y][x][y]-f[p->x][p->y][x][y];
    }
  }
  return printf("%d",ans),0;
}

  

posted @ 2015-06-20 09:19  Claris  阅读(620)  评论(0编辑  收藏  举报