QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#575329#3199. PasswordssongziyanWA 1ms5772kbC++231.5kb2024-09-19 12:21:252024-09-19 12:21:26

Judging History

This is the latest submission verdict.

  • [2024-09-19 12:21:26]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5772kb
  • [2024-09-19 12:21:25]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e6+3,N=55*2;
int L,R,n,tr[N*25][26],cnt,bo[N*25],fail[N*25];
string str;
void insert(){
	int u=0;
	for(auto i:str){
		int ch=i-'a';
		if(!tr[u][ch])tr[u][ch]=++cnt;
		u=tr[u][ch];
	}
	bo[u]=1;
}
queue<int>q;
void build(){
	for(int i=0;i<26;i++)if(tr[0][i])q.push(tr[0][i]);
	while(!q.empty()){
		int x=q.front();q.pop();
		for(int i=0;i<26;i++){
			if(tr[x][i])fail[tr[x][i]]=tr[fail[x]][i],q.push(tr[x][i]);
			else tr[x][i]=tr[fail[x]][i];
		}
	}
	for(int i=1;i<=cnt;i++)bo[i]|=bo[fail[i]];
}
void upd(int &x,int y){
	x+=y;x%=mod;
}
int f[N][N*25][8];
signed main(){
	cin>>L>>R>>n;
	for(int i=1;i<=n;i++){
		cin>>str;
		insert();
	}
	build();
	f[0][0][0]=1;
	for(int i=1;i<=R;i++){
		for(int j=0;j<=cnt;j++)if(!bo[j])
			for(int s=0;s<8;s++)if(f[i-1][j][s]){
			for(int k=0;k<=9;k++){
				int ch=-1;
				if(k==0)ch='o'-'a';
				if(k==1)ch='i'-'a';
				if(k==3)ch='e'-'a';
				if(k==5)ch='s'-'a';
				if(k==7)ch='t'-'a';
				if(ch==-1)upd(f[i][0][s|1],f[i-1][j][s]);
				else if(!bo[tr[j][ch]])upd(f[i][tr[j][ch]][s|1],f[i-1][j][s]);
			}
			for(int k=0;k<26;k++){
				if(!bo[tr[j][k]]){
					upd(f[i][tr[j][k]][s|2],f[i-1][j][s]);
					upd(f[i][tr[j][k]][s|4],f[i-1][j][s]);
				}
			}
		}
	}
	int res=0;
	for(int i=L;i<=R;i++)for(int j=0;j<=cnt;j++)if(!bo[j])upd(res,f[i][j][7]);
	cout<<res;
	return 0;
}
/*
3 5
9
swerc
icpc
fbi
cia
bio
z
hi
no
yes
*/

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5660kb

input:

3 5
9
swerc
icpc
fbi
cia
bio
z
hi
no
yes

output:

607886

result:

ok single line: '607886'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3816kb

input:

4 5
0

output:

887311

result:

ok single line: '887311'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3656kb

input:

3 5
1
a

output:

223848

result:

ok single line: '223848'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3564kb

input:

4 5
10
a
c
e
g
i
k
m
o
q
s

output:

178702

result:

ok single line: '178702'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3628kb

input:

3 4
26
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z

output:

0

result:

ok single line: '0'

Test #6:

score: 0
Accepted
time: 0ms
memory: 5576kb

input:

3 5
8
fcup
porto
swerc
ola
hello
no
yes
abc

output:

839906

result:

ok single line: '839906'

Test #7:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

3 5
10
attc
tcag
gtc
gta
aaaa
ccaaa
ttcg
gacga
aagcg
cagd

output:

796623

result:

ok single line: '796623'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3636kb

input:

3 5
12
a
baz
cbaz
dcbaz
hendb
endb
ndb
b
nn
onno
ayesb
yes

output:

511313

result:

ok single line: '511313'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

4 6
50
hph
h
pp
hhphpp
p
ph
hh
hhpp
hpphhp
hhp
ppphp
pph
pppp
hphph
phhphh
hpph
hphphp
phphp
phphh
hhh
pphp
phhh
pphh
ppphh
phphpp
phh
hpphhh
hhhh
pphph
phpp
phph
hhhhph
hpphh
hp
hpp
pphpp
hhhp
phhp
hhph
ppph
hppph
phhhh
ppppp
hppp
hhphph
hphphh
ppp
hhhpph
hpppp
hppphp

output:

344974

result:

ok single line: '344974'

Test #10:

score: 0
Accepted
time: 0ms
memory: 5684kb

input:

3 6
50
wqog
sjqr
fcbqax
y
xpwwi
j
gklgnc
bmhark
qgaj
uvfpwz
hi
nallwx
obms
oigkq
uehl
r
fq
uqe
rbhbt
luzt
jxyu
fgvrk
s
gidv
jlagzj
cyshm
ixjxu
vkhjh
ibbw
k
zq
b
knav
ayxeqm
rncdp
kzqdww
cdkkw
fjl
hy
l
qsakh
bgju
yzx
sf
emuc
lq
wcaba
wla
yal
e

output:

188830

result:

ok single line: '188830'

Test #11:

score: 0
Accepted
time: 1ms
memory: 5772kb

input:

3 10
25
axaxxx
txrj
tt
tttaxjr
xxxrtj
xttarxxxtx
xaxjr
r
jrrjrxjr
aarajar
txt
x
rt
xatxt
xttj
xjja
xra
jxt
ra
taaxra
aj
rjr
xxaxaaj
xxttrjxa
xxtajx

output:

687381

result:

ok single line: '687381'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

3 15
35
vxkqvdexdx
zxvee
mvozimqezvxqoe
qev
vxiovmmdxq
xozzzm
iqexzoxqievxze
deezqqdkek
zvzodz
veizidqkemvziox
zmzidxidezve
koxdvdm
ozzmii
xvedxqmm
dqziexoe
qdmo
dokieiodoqzdzix
dke
odqo
imeemxvexxzov
veeixmvdq
vdveoqv
ixmezo
dqoeexizokemovo
dddzeokm
ozizmq
izieei
kexzkqmxoqkeo
dkoez
voqmoidimzvm
qq...

output:

841929

result:

ok single line: '841929'

Test #13:

score: -100
Wrong Answer
time: 1ms
memory: 3764kb

input:

10 15
45
aa
rrraxrarrkakxaa
kr
rkrarxrkxrark
kkkakarxrr
rrkakarxrr
axxxaxakkkxxkrk
aaxrrkarxaxaxk
xrxa
aaaakxxkaraar
rxrr
axraaaaxxxxkxk
xx
rrxx
xakkxrrx
k
rkarrxkkrx
rara
xxaarakax
raraakkaaaxa
kxxr
kraxkaxaar
x
xkkkkxxkk
rkkarr
krxkkxkrxkxkxax
araxkkrx
arar
aaa
xaarkxarkxxk
xrk
krrkkxrxa
xaxrkxrax...

output:

238373

result:

wrong answer 1st lines differ - expected: '322551', found: '238373'