题意:链接

方法:乱搞

解析:

出这道题的人存心报复社会。

首先这个单词表…先上网上找这个单词表…

反正总共2265个单词。然后就考虑怎么做即可了。

刚開始我没看表,找不到怎么做,最快的方法我也仅仅是想到了类n^6的做法。

然后我就卡关辣,这关怎么过!

神犇的方法是:观察表。发现规律:

发现表中的单词最长就是4个字母。

所以我们能够考虑求1,2,3,4长度的单词数。

1的话能够直接记录,扫的时候顺带加上即可。

然后神犇说了一句话:

表中长度为4的单词前两个字母同样的单词个数不超过35个。

长度为3前一个字母同样的单词个数不超过7个。

所以直接上链表优化啊?

这种话就要求我们预处理什么呢?

预处理点(i,j)右上角字母x的出现次数。

预处理点(i,j)右上角后缀xy的出现次数。

这个怎么维护啊?

容斥原理啊,所以复杂度在26*26*nm左右,也就是4次方,能够接受。

所以我们仅仅须要枚举开头的两个字母,这是n^4的复杂度,然后再加上链表,枚举次数不超过43=(35+7)。而提取个数由于我们的预处理,变成辣O1啊。所以这种话总共的复杂度是在n^5的。

掉了一个n啊!

这不就能过了吗!

orz出题人。

单词表:

A
AA
AAA
AAAA
ABBE
ABED
ABET
ABLE
ABLY
ABUT
ACE
ACES
ACHE
ACID
ACME
ACNE
ACRE
ACT
AD
ADD
ADDS
ADO
ADS
AFAR
AFT
AGAR
AGE
AGED
AGER
AGES
AGO
AGOG
AGUE
AH
AID
AIDE
AIDS
AIL
AIM
AIMS
AIR
AIRS
AIRY
AJAR
AKIN
ALAS
ALBA
ALE
ALEE
ALGA
ALL
ALLY
ALMA
ALMS
ALOE
ALSO
ALUM
AM
AMEN
AMID
AMMO
AMOK
AMYL
AN
ANAL
AND
ANEW
ANON
ANT
ANTE
ANTI
ANTS
ANUS
ANY
APE
APED
APES
APEX
APSE
APT
AQUA
ARC
ARCH
ARCS
ARE
AREA
ARID
ARK
ARM
ARMS
ARMY
ART
ARTS
AS
ASH
ASK
ASKS
ASP
ASS
AT
ATE
ATOM
ATOP
AUNT
AURA
AUTO
AVER
AVID
AVOW
AWAY
AWE
AWED
A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
CHEW
CHIC
CHIN
CHIP
CHIT
CHOP
CHUM
CITE
CITY
CLAD
CLAM
CLAN
CLAP
CLAW
CLAY
CLIP
CLOD
CLOG
CLOT
CLUB
CLUE
COAL
COAT
COAX
COCA
COCK
COCO
COD
CODE
COED
COG
COGS
COIL
COIN
COKE
COLD
COLT
COMB
COME
CON
CONE
COO
COOK
COOL
COON
COOP
COP
COPE
COPS
COPY
CORD
CORE
CORK
CORN
COST
COSY
COT
COTS
COVE
COW
COWL
COWS
COZY
CRAB
CRAG
CRAM
CREW
CRIB
CROP
CROW
CRUD
CRUX
CRY
CUB
CUBE
CUBS
CUE
CUED
CUES
CUFF
CULL
CULT
CUP
CUPS
CURB
CURD
CURE
CURL
CURS
CURT
CUSP
CUT
CUTE
CUTS
CYST
CZAR
DAD
DADS
DALE
DAM
DAME
DAMN
DAMP
DAMS
DARE
DARK
DARN
DART
DASH
DATA
DATE
DAWN
DAY
DAYS
DAZE
DEAD
DEAF
DEAL
DEAN
DEAR
DEBT
DECK
DEED
DEEM
DEEP
DEER
DEFY
DELL
DEMO
DEN
DENS
DENT
DENY
DESK
DEUS
DEW
DEWY
DIAL
DICE
DID
DIE
DIED
DIEM
DIES
DIET
DIG
DIGS
DIKE
DILL
DIM
DIME
DIMS
DIN
DINE
DING
DINT
DIP
DIPS
DIRE
DIRT
DISC
DISH
DISK
DIVE
DO
DOCK
DOE
DOER
DOES
DOG
DOGS
DOLE
DOLL
DOME
DON
DONE
DONS
DOOM
DOOR
DOPE
DOSE
DOT
DOTE
DOTS
DOVE
DOWN
DOZE
DRAB
DRAG
DRAM
DRAW
DREW
DRIP
DROP
DRUG
DRUM
DRY
DUAL
DUB
DUBS
DUCK
DUCT
DUD
DUE
DUEL
DUES
DUET
DUG
DUKE
DULL
DULY
DUMB
DUMP
DUNE
DUNG
DUNK
DUPE
DUSK
DUST
DUTY
DYAD
DYE
DYED
DYER
DYES
DYNE
EACH
EAR
EARL
EARN
EARS
EASE
EAST
EASY
EAT
EATS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ERK
JEST
JET
JETS
JIG
JIGS
JOB
JOBS
JOG
JOGS
JOIN
JOKE
JOLT
JOT
JOTS
JOY
JOYS
JUDO
JUG
JUGS
JUMP
JUNK
JURE
JURY
JUST
JUT
KEEL
KEEN
KEEP
KEN
KEPT
KERN
KEY
KEYS
KICK
KID
KIDS
KILL
KIN
KIND
KING
KINK
KISS
KIT
KITE
KITS
KNEE
KNEW
KNIT
KNOB
KNOT
KNOW
KUDO
LAB
LABS
LACE
LACK
LACY
LAD
LADS
LADY
LAG
LAGS
LAID
LAIN
LAIR
LAKE
LAMB
LAME
LAMP
LAND
LANE
LAP
LAPS
LARD
LARK
LASH
LASS
LAST
LATE
LAVA
LAW
LAWN
LAWS
LAX
LAY
LAYS
LAZY
LEAD
LEAF
LEAK
LEAN
LEAP
LED
LEE
LEEK
LEER
LEES
LEFT
LEG
LEGS
LEND
LENS
LENT
LESS
LEST
LET
LETS
LEVY
LEWD
LIAR
LICE
LICK
LID
LIDS
LIE
LIED
LIEN
LIES
LIEU
LIFE
LIFT
LIKE
LILY
LIMB
LIME
LIMP
LINE
LINK
LINT
LION
LIP
LIPS
LISP
LIST
LIT
LIVE
LOAD
LOAF
LOAN
LOBE
LOCI
LOCK
LOFT
LOGO
LOGS
LOIN
LONE
LONG
LOOK
LOOM
LOON
LOOP
LOOT
LORD
LORE
LOSE
LOSS
LOST
LOT
LOTS
LOUD
LOUT
LOVE
LOW
LOWS
LUCK
LULL
LUMP
LUNG
LURE
LURK
LUSH
LUST
LUTE
LYNX
LYRE
MACE
MAD
MADE
MAID
MAIL
MAIM
MAIN
MAKE
MALE
MALL
MALT
MAMA
MAN
MANE
MANY
MAP
MAPS
MARE
MARK
MART
MASH
MASK
MASS
MAST
MAT
MATE
MATH
MATS
MAUL
MAZE
ME
MEAD
MEAL
MEAN
MEAT
MEEK
MEET
MELT
MEMO
MEN
MEND
MENS
MENU
MERE
MESH
MESS
MET
META
METE
METS
MEW
MEWS
MICA
MICE
MID
MIEN
MIKE
M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ICA
PICK
PIE
PIER
PIES
PIG
PIGS
PIKE
PILE
PILL
PIMP
PIN
PINE
PING
PINK
PINS
PINT
PION
PIP
PIPE
PISS
PIT
PITH
PITS
PITY
PLAN
PLAY
PLEA
PLOD
PLOT
PLOW
PLOY
PLUG
PLUM
PLUS
PLY
POD
PODS
POEM
POET
POGO
POKE
POLE
POLL
POLO
POMP
POND
PONG
PONY
POOL
POOR
POP
POPS
PORE
PORK
PORT
POSE
POSH
POST
POT
POTS
POUR
POUT
POX
PRAY
PREP
PREY
PRIM
PRO
PROD
PROP
PROS
PROW
PRY
PUB
PUBS
PUFF
PUKE
PULL
PULP
PUMA
PUMP
PUN
PUNS
PUNT
PUNY
PUP
PUPA
PUPS
PURE
PURR
PUS
PUSH
PUSS
PUT
PUTS
PUTT
PYRE
QUA
QUAD
QUAY
QUIP
QUIT
QUIZ
QUO
RACE
RACK
RAFT
RAG
RAGE
RAGS
RAID
RAIL
RAIN
RAKE
RAM
RAMP
RAMS
RAN
RANG
RANK
RANT
RAP
RAPE
RAPS
RAPT
RARE
RASH
RASP
RAT
RATE
RATS
RAVE
RAW
RAY
RAYS
RAZE
RE
READ
REAL
REAM
REAP
REAR
RED
REDO
REDS
REED
REEF
REEL
REIN
RELY
REND
RENT
REST
RHO
RIB
RIBS
RICE
RICH
RID
RIDE
RIDS
RIFT
RIG
RIGS
RILL
RIM
RIME
RIMS
RIND
RING
RINK
RIOT
RIP
RIPE
RIPS
RISE
RISK
RITE
ROAD
ROAM
ROAR
ROB
ROBE
ROBS
ROCK
ROD
RODE
RODS
ROE
ROLE
ROLL
ROMP
ROOF
ROOK
ROOM
ROOT
ROPE
ROSY
ROT
ROTS
ROUT
ROVE
ROW
ROWS
RUB
RUBS
RUBY
RUDE
RUE
RUG
RUGS
RUIN
RULE
RUM
RUMP
RUN
RUNG
RUNS
RUNT
RUSH
RUST
RUT
RUTS
RYE
SACK
SAD
SAFE
SAG
SAGA
SAGE
SAGS
SAID
SAIL
SAKE
SALE
SAL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
TASK
TAU
TAUT
TAX
TAXI
TEA
TEAM
TEAR
TEAS
TEEM
TEEN
TELL
TEN
TEND
TENS
TENT
TERM
TEST
TEXT
THAN
THAT
THAW
THE
THEM
THEN
THEY
THIN
THIS
THUD
THUG
THUS
TICK
TIDE
TIDY
TIE
TIED
TIER
TIES
TILE
TILL
TILT
TIME
TIN
TINS
TINT
TINY
TIP
TIPS
TIRE
TIT
TITS
TO
TOAD
TOE
TOES
TOIL
TOLD
TOLL
TOMB
TON
TONE
TONS
TOO
TOOK
TOOL
TOP
TOPS
TORE
TORN
TOSS
TOUR
TOW
TOWN
TOY
TOYS
TRAP
TRAY
TREE
TREK
TRIM
TRIO
TRIP
TROD
TROT
TRUE
TRY
TUB
TUBE
TUBS
TUCK
TUFT
TUG
TUGS
TUNE
TURF
TURN
TWAS
TWIG
TWIN
TWO
TWOS
TYPE
TYPO
UGH
UGLY
UNDO
UNIT
UNTO
UP
UPON
URGE
URN
URNS
US
USE
USED
USER
USES
VAIN
VALE
VAN
VANE
VANS
VARY
VASE
VAST
VAT
VATS
VEAL
VEER
VEIL
VEIN
VENT
VERB
VERY
VEST
VETO
VEX
VIA
VIAL
VICE
VIE
VIED
VIER
VIES
VIEW
VILE
VINE
VISA
VITA
VOID
VOLT
VOTE
VOW
VOWS
WADE
WAFT
WAG
WAGE
WAGS
WAIL
WAIT
WAKE
WALK
WALL
WAN
WAND
WANE
WANT
WAR
WARD
WARE
WARM
WARN
WARP
WARS
WART
WARY
WAS
WASH
WASP
WAVE
WAX
WAXY
WAY
WAYS
WE
WEAK
WEAN
WEAR
WEB
WEBS
WEDS
WEE
WEED
WEEK
WEEP
WELD
WELL
WENT
WEPT
WERE
WEST
WET
WETS
WHAT
WHEN
WHIM
WHIP
WHIT
WHIZ
WHO
WHOM
WHY
WICK
WIDE
WIFE
WIG
WIGS
WILD
WILE
WILL
WILT
WILY
WIN
WIND
WINE
WING
WINK
WINS
WIPE
WIRE
WIRY
WISE
WISH
WISP
WIT
WITH
WITS
WOE
WOKE
WOLF
WOMB
WON
WONT
WOO
WOOD
WOOF
WOOL
WOOS
WORD
WORE
WORK
WORM
WORN
WOVE
WRAP
WREN
WRIT
YANK
YARD
YARN
YAWN
YEA
YEAR
YEAS
YELL
YELP
YES
YET
YOKE
YON
YOU
YOUR
ZEAL
ZERO
ZEST
ZINC
ZONE
ZOO
ZOOM
ZOOS

代码:(因单词表在上方给出,所以此处略)

#include <cstdio>
#include <string>
#include <cstring>
#include <iostream>
#include <algorithm>
#define N 35
using namespace std;
string d[2265];
int map[N][N];
int sum1[N][N][N];
int sum2[N][N][N][N];
int fuck[N][N][N][N];
int head[N][N];
int head2[N][N];
int v[N];
int v1[N][N];
int cnt,cnt2;
int n,m;
struct node
{
int fromx,fromy,x,y,next;
}edge[2265],edge2[2265];
void init()
{
memset(head,-1,sizeof(head));
memset(head2,-1,sizeof(head2));
cnt=1,cnt2=1;
}
void edgeadd(int fromx,int fromy,int to)
{
edge[cnt].fromx=fromx,edge[cnt].fromy=fromy;
edge[cnt].x=to;
edge[cnt].next=head[fromx][fromy];
head[fromx][fromy]=cnt++;
}
void edgeadd2(int fromx,int fromy,int to,int to2)
{
edge2[cnt2].fromx=fromx,edge2[cnt2].fromy=fromy;
edge2[cnt2].x=to,edge2[cnt2].y=to2;
edge2[cnt2].next=head2[fromx][fromy];
head2[fromx][fromy]=cnt2++;
}
char s[N];
int main()
{
//此处放单词表,多背单词少刷水!! !!。!!。! 。!!!。!!
init();
for(int i=0;i<=2264;i++)
{
int len=d[i].size();
switch(len)
{
case 1:v[d[i][0]-'A']=1;break;
case 2:v1[d[i][0]-'A'][d[i][1]-'A']=1;break;
case 3:edgeadd(d[i][0]-'A',d[i][1]-'A',d[i][2]-'A');break;
case 4:edgeadd2(d[i][0]-'A',d[i][1]-'A',d[i][2]-'A',d[i][3]-'A');break;
}
}
scanf("%d%d",&n,&m);
for(int i=1;i<=n;i++)
{
scanf("%s",s+1);
for(int j=1;j<=m;j++)
{
map[i][j]=s[j]-'A';
}
}
for(int i=0;i<26;i++)
{
for(int j=1;j<=n;j++)
{
for(int k=m;k>=1;k--)
{
sum1[i][j][k]=sum1[i][j-1][k]+sum1[i][j][k+1]-sum1[i][j-1][k+1]+(map[j][k]==i);
fuck[map[j][k]][i][j][k]=sum1[i][j][k]-(map[j][k]==i);
}
}
}
for(int i=0;i<26;i++)
{
for(int j=0;j<26;j++)
{
for(int k=1;k<=n;k++)
{
for(int l=m;l>=1;l--)
{
sum2[i][j][k][l]=sum2[i][j][k-1][l]+sum2[i][j][k][l+1]-sum2[i][j][k-1][l+1]+fuck[i][j][k][l];
}
}
}
}
int ans=0;
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(v[map[i][j]])ans++;
for(int x=i;x>=1;x--)
{
for(int y=j;y<=m;y++)
{
if(x==i&&y==j)continue;
if(v1[map[i][j]][map[x][y]])ans++;
for(int k=head[map[i][j]][map[x][y]];k!=-1;k=edge[k].next)
{
int to=edge[k].x;
ans+=sum1[to][x][y]-(map[x][y]==to);
}
for(int k=head2[map[i][j]][map[x][y]];k!=-1;k=edge2[k].next)
{
int to=edge2[k].x;
int to2=edge2[k].y;
ans+=sum2[to][to2][x][y]-fuck[to][to2][x][y];
}
}
}
}
}
printf("%d\n",ans);
}

BZOJ 1695 [Usaco2007 Demo]Walk the Talk 链表+数学的更多相关文章

  1. BZOJ1695 : [Usaco2007 Demo]Walk the Talk

    观察单词表可以发现: 对于长度为3的单词,前两个字母相同的单词不超过7个 对于长度为4的单词,前两个字母相同的单词不超过35个 于是首先$O(26*26*nm)$预处理出 s1[x][i][j]表示( ...

  2. BZOJ 1629: [Usaco2007 Demo]Cow Acrobats

    Description Farmer John's N (1 <= N <= 50,000) cows (numbered 1..N) are planning to run away a ...

  3. BZOJ 1628 [Usaco2007 Demo]City skyline:单调栈

    题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1628 题意: 题解: 单调栈. 单调性: 栈内元素高度递增. 一旦出现比栈顶小的元素,则表 ...

  4. bzoj 1630: [Usaco2007 Demo]Ant Counting【dp】

    满脑子组合数学,根本没想到dp 设f[i][j]为前i只蚂蚁,选出j只的方案数,初始状态为f[0][0]=1 转移为 \[ f[i][j]=\sum_{k=0}^{a[i]}f[i-1][j-k] \ ...

  5. bzoj 1628: [Usaco2007 Demo]City skyline【贪心+单调栈】

    还以为是dp呢 首先默认答案是n 对于一个影子,如果前边的影子比它高则可以归进前面的影子,高处的一段单算: 和他一样高的话就不用单算了,ans--: 否则入栈 #include<iostream ...

  6. bzoj 1629: [Usaco2007 Demo]Cow Acrobats【贪心+排序】

    仿佛学到了贪心的新姿势-- 考虑相邻两头牛,交换它们对其他牛不产生影响,所以如果交换这两头牛能使这两头牛之间的最大值变小,则交换 #include<iostream> #include&l ...

  7. BZOJ1629: [Usaco2007 Demo]Cow Acrobats

    1629: [Usaco2007 Demo]Cow Acrobats Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 601  Solved: 305[Su ...

  8. BZOJ1628: [Usaco2007 Demo]City skyline

    1628: [Usaco2007 Demo]City skyline Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 256  Solved: 210[Su ...

  9. 【BZOJ1630/2023】[Usaco2007 Demo]Ant Counting DP

    [BZOJ1630/2023][Usaco2007 Demo]Ant Counting 题意:T中蚂蚁,一共A只,同种蚂蚁认为是相同的,有一群蚂蚁要出行,个数不少于S,不大于B,求总方案数 题解:DP ...

随机推荐

  1. JavaWeb学习笔记:Tomcat

    Tomcat 开源的 Servlet 容器. 部署并启动 tomcat server. 解压 apache-tomcat-6.0.16.zip 到一个非中文文件夹下. 配置一个环境变量. java_h ...

  2. BASH 文本模版的简单实现 micro_template_compile

    详细代码 ############################### # # Funciton: micro_template_compile # # Parameter: # [1] => ...

  3. Windows 98 二十岁了,这些功能都是从它开始的(虽然 Windows 98 不如 Windows 95 那样具有革命性,但完成度更高,更加成熟。到最后还是:相见不如怀念。)

    1998 年 6 月 25 日午夜,美国著名连锁零售店 CompUSA 门外挤满了狂热的消费者和媒体,他们在等待一款软件发售:Windows 98,即使明知它要到当天早上才正式上市. ▲ 在 Comp ...

  4. POJ 题目1145/UVA题目112 Tree Summing(二叉树遍历)

    Tree Summing Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 8132   Accepted: 1949 Desc ...

  5. 团队作业-Beta冲刺(3)

    这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/SoftwareEngineeringClass2 这个作业要求在哪里 https://edu.cnblo ...

  6. QT常用代码之加载动态库和弹出对话框

    作者:朱金灿 来源:http://blog.csdn.net/clever101 加载动态库的代码: typedef void (*Execute)(); // 定义导出函数类型 QString st ...

  7. Angular:内置指令

    [ngIf]表达式结果为真,显示元素:表达式结果为假,移除元素. <div *ngIf="a > b"></div> [ngSwitch]对表达式进行 ...

  8. linux监测tomcat服务

    原文链接:https://blog.csdn.net/qq_37936542/article/details/81086928 项目上线之后,tomcat服务器有时候会莫名其妙的挂掉,利用shell写 ...

  9. 三菱FX系列PLC学习

    1.PLC工作原理 PLC将程序存储在用户存储器当中, 驱动其运行, 相对比微型计算机软件, PLC程序则不同的是, 微型计算机整个流程则是从规定的开始 至结束完整工作流程.相对与PLC运行,则是从位 ...

  10. Android控件:RadioButton(单选button)

    watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/ ...