QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#838490#9921. YelkrabHuTaoTL 724ms222624kbC++141.1kb2024-12-31 12:18:112024-12-31 12:18:16

Judging History

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

  • [2024-12-31 12:18:16]
  • 评测
  • 测评结果:TL
  • 用时:724ms
  • 内存:222624kb
  • [2024-12-31 12:18:11]
  • 提交

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;
}

Details

Tip: Click on the bar to expand more detailed information

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...

output:


result: