QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#577170#3199. PasswordssongziyanCompile Error//C++231.5kb2024-09-20 08:44:282024-09-20 08:44:29

Judging History

This is the latest submission verdict.

  • [2024-09-20 08:44:29]
  • Judged
  • [2024-09-20 08:44:28]
  • 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();bo[i]|=bo[fail[i]];
		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
*/

詳細信息

answer.code: In function ‘void build()’:
answer.code:20:44: error: ‘i’ was not declared in this scope
   20 |                 int x=q.front();q.pop();bo[i]|=bo[fail[i]];
      |                                            ^