QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#836221#9921. Yelkrabucup-team045#WA 1ms5876kbC++201.8kb2024-12-28 17:26:012024-12-28 17:26:10

Judging History

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

  • [2024-12-28 17:26:10]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5876kb
  • [2024-12-28 17:26:01]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
#include<map>
using namespace std;
using LL = long long;
const int maxn = 1000005, N = 10;
vector<int> factor[N + 5];
int tr[maxn][26];
int sz[maxn];
int idx;
vector<int> modify[N + 5];

void clear(){
    for(int i = 0; i <= idx; i++){
        sz[i] = 0;
        tr[i][0] = tr[i][1] = 0;
    }
    idx = 0;
}

void insert(const string &s, int tim){
    int p = 0;
    for(auto c : s){
        int x = c - 'a';
        if (!tr[p][x]) tr[p][x] = ++idx;
        p = tr[p][x];
        for(auto y : factor[sz[p] + 1]){
            modify[y].push_back(tim);
        }
        sz[p] += 1;
    }
}

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    for(int i = 1; i <= N; i++){
        for(int j = i; j <= N; j += i){
            factor[j].push_back(i);
        }
    }

    int T;
    cin >> T;
    while(T--){
        clear();
        int n;
        cin >> n;
        for(int j = 1; j <= n; j++){
            modify[j].clear();
            modify[j].push_back(j);
        }
        for(int i = 1; i <= n; i++){
            string s;
            cin >> s;
            insert(s, i);
        }

        vector<int> ans(n + 2);

        for(int j = 1; j <= n; j++){
            modify[j].push_back(n + 1);
            for(int i = 0; i + 1 < modify[j].size(); i++){
                int l = modify[j][i], r = modify[j][i + 1];
                ans[l] ^= i * j;
                ans[r] ^= i * j;
            }
        }
        for(int i = 1; i <= n; i++){
            ans[i] ^= ans[i - 1];
            cout << ans[i] << " \n"[i == n];
        }
    }

}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 5876kb

input:

2
5
aa
ab
ab
ac
d
1
aaaaa

output:

2 6 1 9 8
5

result:

ok 6 numbers

Test #2:

score: 0
Accepted
time: 1ms
memory: 5644kb

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 76 67 75 120
3 1 8 31 41 40 43 55 58 54
95 146
32 38 39 41 51 79 79 70 70 112
3 22 47 90 91 117 129 146 157
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 102 118
50

result:

ok 71 numbers

Test #3:

score: -100
Wrong Answer
time: 1ms
memory: 5684kb

input:

100
6
baaaab
aadabdbdadabbbbcda
ccbc
b
dccaddba
da
7
aad
dababba
addbdbbbbdabdaadacbabadabdcccbdccabadbbddddaaaddbdbcaa
abcddd
c
bddcc
ca
9
daadbbcaa
bacbdbaab
bcbaba
acbcbd
ac
b
bddcddcdccacdcbbccaccdbc
dabbdccabb
accbbbc
12
bcbdabba
ac
b
cdbbaa
cdaa
bddac
bbacbcaacbbbbbaa
b
dadcbd
bcc
bbbdbcdacbbb...

output:

6 24 28 31 39 35
3 10 77 78 73 66 79
8 21 29 27 41 45 42 79 74
8 10 9 19 19 22 37 43 61 15 125 124
11 24 55 51 112 88
7 101
28 210 131 131 351 275 354 371
7 19 21 59 58 39 9 25 25 113 55 46
40
1 0 26 4
126
113 28 27
24 12 20 100 3 12 204
1 8 4 23 19 37 57 7 22 47 69 68
226
8 27 26 11 12 15
2 0 3
2 7...

result:

wrong answer 9th numbers differ - expected: '66', found: '77'