QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#838490 | #9921. Yelkrab | HuTao | TL | 724ms | 222624kb | C++14 | 1.1kb | 2024-12-31 12:18:11 | 2024-12-31 12:18:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 5;
int n;
char s[N];
int tr[N][26], cnt[N], tot;
vector<int> d[N];
int f[N];
long long ans;
inline void Add(int i)
{
ans ^= 1LL * f[i] * i;
f[i] ++ ;
ans ^= 1LL * f[i] * i;
}
inline void Init()
{
for(int i = 1; i < N; i ++ )
for(int j = i; j < N; j += i)
d[j].push_back(i);
}
inline void Update(int i)
{
cnt[i] ++ ;
for(int j : d[cnt[i]]) Add(j);
}
inline void Insert()
{
for(int i = 0, u = 0; s[i]; i ++ )
{
int ch = s[i] - 'a';
if(!tr[u][ch]) tr[u][ch] = ++ tot;
u = tr[u][ch];
Update(u);
}
}
inline void Clear()
{
for(int i = 0; i <= tot; i ++ )
{
memset(tr, 0, sizeof tr);
cnt[i] = f[i] = 0;
}
tot = ans = 0;
}
inline void Solve()
{
scanf("%d", &n);
Clear();
for(int i = 1; i <= n; i ++ ) scanf("%s", s), Insert(), printf("%lld ", ans);
puts("");
}
int main()
{
Init();
int T;
scanf("%d", &T);
while(T -- ) Solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 724ms
memory: 222624kb
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
Time Limit Exceeded
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...