QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#851254 | #9921. Yelkrab | asdf__ | WA | 773ms | 184480kb | C++14 | 1.2kb | 2025-01-10 16:58:28 | 2025-01-10 16:58:29 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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'