QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#575292#3199. PasswordssongziyanWA 1ms5856kbC++231.4kb2024-09-19 11:53:232024-09-19 11:53:23

Judging History

This is the latest submission verdict.

  • [2024-09-19 11:53:23]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5856kb
  • [2024-09-19 11:53:23]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int mod=1e6+3,N=55;
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];
		}
	}
}
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: 0ms
memory: 3664kb

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: 1ms
memory: 5856kb

input:

3 5
1
a

output:

223848

result:

ok single line: '223848'

Test #4:

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

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: 3584kb

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: 3844kb

input:

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

output:

796623

result:

ok single line: '796623'

Test #8:

score: -100
Wrong Answer
time: 0ms
memory: 3844kb

input:

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

output:

742954

result:

wrong answer 1st lines differ - expected: '511313', found: '742954'