QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#851345#9921. Yelkrabasdf__WA 785ms189316kbC++141.3kb2025-01-10 18:01:082025-01-10 18:01:08

Judging History

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

  • [2025-01-10 18:01:08]
  • 评测
  • 测评结果:WA
  • 用时:785ms
  • 内存:189316kb
  • [2025-01-10 18:01:08]
  • 提交

answer

#include<iostream>
#include<vector>
#include<string>
#include<map> 
#include<cstring>
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]=min(le,la+1);
				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(){
//	freopen("1.in","r",stdin);
//	freopen("1.out","w",stdout);
	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;
			la=0;
			init();
			cout<<da<<' ';
		}
		cout<<endl;
		da=0;
		for(int i=1;i<=n;i++) ans[i]=0;
		for(int i=0;i<=cn;i++) cnt[i]=0,memset(tr[i],0,sizeof(tr[i]));
		la=cn=0;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 742ms
memory: 189316kb

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: 785ms
memory: 188984kb

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 35 35 32 60 75 78 69 77 122 
3 1 8 31 41 40 43 55 58 54 
95 146 
32 38 39 41 51 79 79 70 68 116 
3 22 47 90 91 117 129 148 147 
40 53 62 63 
12 46 51 51 83 111 99 113 126 106 
10 45 48 49 89 
12 22 28 37 61 67 70 123 109 127 
50 

result:

wrong answer 7th numbers differ - expected: '76', found: '78'