题意:链接

方法:乱搞

解析:

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

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

反正总共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. UVA - 10674-Tangents

     题意:给出两个圆,求它们的公切线,并依照一定格式输出 做法:模拟 代码: #include<iostream> #include<map> #include<str ...

  2. HTML5手机应用的最大优势就是可以在网页上直接调试和修改

    HTML5手机应用的最大优势就是可以在网页上直接调试和修改

  3. File Upload with Jersey

    package com.toic.rest; import java.io.File; import java.io.FileOutputStream; import java.io.IOExcept ...

  4. Vue的style与class

    1. style 可以通过 :style="{height:`${heightData.main}px`}" 实现样式的动态绑定, style绑定的是一个对象,多个样式时用“,”隔 ...

  5. numpy_basic3

    矩陣 矩阵是numpy.matrix类类型的对象,该类继承自numpy.ndarray,任何针对多维数组的操作,对矩阵同样有效,但是作为子类矩阵又结合其自身的特点,做了必要的扩充,比如:乘法计算.求逆 ...

  6. 理解宏的使用 extern

    如何定义一个全局变量在一个文件中,然后在其它文件中调用就行,而不需要多次extern外部声明. 由于之前的公司的程序中全局的变量使用得很多,在多个.C文件中会调用,不这样处理做的话就会多处进行exte ...

  7. C# Unity依赖注入利用Attribute实现AOP功能

    使用场景? 很多时候, 我们定义一个功能, 当我们要对这个功能进行扩展的时候, 按照常规的思路, 我们一般都是利用OOP的思想, 在原有的功能上进行扩展. 那么有没有一种东西, 可以实现当我们需要扩展 ...

  8. CSS3制作W3cplus的关注面板

    <!DOCTYPE HTML> <html lang="en-US"> <head> <meta charset="UTF-8& ...

  9. zico源代码分析(二) 数据读取和解析部分

    第一部分:分析篇 首先,看一下zico的页面,左侧是hostname panel,右侧是该主机对应的traces panel. 点击左侧zorka主机名,右侧panel会更新信息,在火狐浏览器中使用f ...

  10. android对话框(Dialog)的使用方法

    Activities提供了一种方便管理的创建.保存.回复的对话框机制.比如 onCreateDialog(int), onPrepareDialog(int, Dialog), showDialog( ...