QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#851254#9921. Yelkrabasdf__WA 773ms184480kbC++141.2kb2025-01-10 16:58:282025-01-10 16:58:29

Judging History

你现在查看的是最新测评结果

  • [2025-01-10 16:58:29]
  • 评测
  • 测评结果:WA
  • 用时:773ms
  • 内存:184480kb
  • [2025-01-10 16:58:28]
  • 提交

answer

#include<iostream>
#include<vector>
#include<string>
#include<map> 
using namespace std;
#define int long long 
const int N=1e6+5;
int n,ans[N],da,T,tr[N][26],cnt[N],cn,fa[N],pd[N],la;
vector<int> a[N];
string c;
void init(){
	int g=0;
	for(int i=0;i<(int)c.length();i++){
		if(cnt[tr[g][c[i]-'a']]) la=i+1;
		else{
			tr[g][c[i]-'a']=++cn;
			fa[cn]=g;
		}
		g=tr[g][c[i]-'a'];
		cnt[g]++;
	}
	int v=g,le=c.length();
	while(v){
		for(int i=0;i<(int)a[cnt[v]].size();i++){
			int u=a[cnt[v]][i];
			if(!pd[u]){
				pd[u]=le;
				da^=ans[u];
				ans[u]+=u*max(le-la,1ll);
				da^=ans[u];
			}
			else if(la>=le){
				da^=ans[u];
				ans[u]+=(pd[u]-le)*u;
				pd[u]=le;
				da^=ans[u];
			}
		}
		v=fa[v];
		le--;
	}
	v=g;
	while(v){
		for(int i=0;i<(int)a[cnt[v]].size();i++){
			int u=a[cnt[v]][i]; 
			pd[u]=0;
		}
		v=fa[v];
	}
}
signed main(){
	cin>>T;
	for(int i=1;i<=1e6;i++){
		for(int j=1;j*i<=1e6;j++){
			a[i*j].push_back(i);
		}
	}
	while(T--){
		cin>>n;
		for(int i=1;i<=n;i++){
			cin>>c;
			init();
			cout<<da<<' ';
		}
		cout<<endl;
		da=0;
		for(int i=1;i<=n;i++) ans[i]=0;
		for(int i=1;i<=cn;i++) cnt[i]=0;
		la=cn=0;
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 773ms
memory: 184460kb

input:

2
5
aa
ab
ab
ac
d
1
aaaaa

output:

2 6 1 9 8 
5 

result:

ok 6 numbers

Test #2:

score: -100
Wrong Answer
time: 763ms
memory: 184480kb

input:

10
10
bba
bbaaaabbbaaabaabbbaaaaaababaababbb
b
baaabbaab
babbb
bbbbbaaaaababbabbabbb
bbaaaabbabb
b
aaaaabab
abbbabbabab
10
abb
ab
bbaaaba
bbabbabba
bbbabbbababaaaab
b
aaaa
babababbb
ab
a
2
aaaaabbaabbbbbababbbbbaabababbbaaababbbaaaaabbbaabaabababbaababbabbabbaababbbbbabbbabaaabbbabab
abbaaaaaaaabbaa...

output:

3 69 65 91 83 128 149 128 142 160 
3 1 15 22 57 37 36 75 86 94 
95 175 
32 38 37 56 49 106 74 98 75 0 
3 35 16 230 236 25 223 204 226 
40 41 33 23 
12 91 87 80 18 110 90 143 151 3 
10 81 81 66 117 
12 30 27 5 22 13 39 14 12 247 
50 

result:

wrong answer 2nd numbers differ - expected: '35', found: '69'