QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#848492#9921. YelkrabHuangGuangshengTL 376ms343076kbC++231.6kb2025-01-08 20:52:142025-01-08 20:52:16

Judging History

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

  • [2025-01-08 20:52:16]
  • 评测
  • 测评结果:TL
  • 用时:376ms
  • 内存:343076kb
  • [2025-01-08 20:52:14]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=2e6+10;
typedef long long ll;
typedef pair<ll,ll> PII;
int n,m,k;
ll a[N],b[N],c[N],dep[N];
// char s[N];
int tr[N][26];
string s[N];
int idx=0;
multiset<PII> se[N];
ll ans;


void insert(string &s){
    int p=0;
    for(int i=0;i<s.size();i++){
        int t=s[i]-'a';
        if(!tr[p][t]){
             tr[p][t]=++idx;
             dep[tr[p][t]]=dep[p]+1;
        }
        p=tr[p][t];
    }
}
void cal(string &s){
    int p=0;
    for(int i=0;i<s.size();i++){
        
        
        // cout<<ans<<endl;
        // ll val=1ll*c[p]*dep[p];
        // ans^=val;
        c[p]++;
        
        int t=s[i]-'a';
        p=tr[p][t];
    }
    c[p]++;
    // ans=0;
    // for(int i=1;i<=)
    

}

void __(){
    for(int i=0;i<=idx;i++){
        for(int j=0;j<26;j++) tr[i][j]=0;
        c[i]=0;
        dep[i]=0;
    }
    
    idx=0;
    int totlen=0;
    for(int i=1;i<=n;i++) se[i].clear();
    // scanf("%d",&n);
    cin>>n;
    for(int i=1;i<=n;i++){
        cin>>s[i];
        insert(s[i]);   
    }
    for(int i=0;i<=idx;i++){
        // cout<<i<<" "<<dep[i]<<endl;
        se[0].insert({dep[i],i});
    }
    ans=0;
    for(int i=1;i<=n;i++){
        cal(s[i]);
        ans=0;
        for(int j=1;j<=i;j++){
            ll res=0;
            for(int k=1;k<=idx;k++){
                res+=c[k]/j;
            }
            ans^=(res*j);
        }
        cout<<ans<<" ";
    }
    cout<<"\n";
}
//2*1 1*2

int main(){
    ios::sync_with_stdio(0);
    int _=1;
    cin>>_;
    while(_--){
        __();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 15ms
memory: 160596kb

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: 15ms
memory: 160536kb

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: 0
Accepted
time: 16ms
memory: 161996kb

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 66 71 70 77 73 
9 18 26 28 38 36 54 72 75 
8 10 9 19 19 31 37 33 59 57 73 82 
9 23 33 39 70 68 
15 81 
19 182 241 252 262 306 321 352 
14 26 24 37 33 38 51 48 57 105 112 116 
40 
1 0 22 54 
126 
64 120 125 
17 28 51 66 103 104 131 
1 13 19 29 31 47 47 45 62 61 71 69 
226 
10 2...

result:

ok 698 numbers

Test #4:

score: 0
Accepted
time: 20ms
memory: 160676kb

input:

100
1
aaabbbbaaabbabbaabbababababab
12
abb
a
bbab
b
aaabbabaaabbbba
bb
baba
bb
a
aba
abaabb
bb
7
aa
aaabaabbaabbaabaaaaaaabbabbaabbb
bbaaabaaaaaababbababbbaabbbbabbbaabbaabaaabbbaaababaaaaaabbabaaaabbaab
aaabbbaaaabaaabababbaabaaabbbbbbbaabaabbbaabbbbbbaaabb
abababbbabbabaaabaabbbbbbaaa
ababaaababab...

output:

29 
3 6 10 13 31 26 20 32 47 35 49 32 
2 38 108 144 178 248 253 
12 28 40 84 125 107 134 143 174 230 211 221 
1 0 7 9 12 13 10 14 
19 20 38 42 
1 5 11 10 10 
7 19 23 
11 16 18 29 85 112 97 233 
1 4 7 4 0 25 31 39 50 57 56 56 
3 7 11 11 13 0 26 27 7 8 6 54 
40 
72 108 136 151 159 157 153 200 246 201 ...

result:

ok 711 numbers

Test #5:

score: 0
Accepted
time: 20ms
memory: 160880kb

input:

100
5
bababccabcacccb
ccaabaa
ccbaacbabbacc
bcbcbccbcababbcccccabc
baaaac
8
c
abcabbbcc
cacbcbbbbaabbabacb
cbb
a
c
acccbaacabbccbca
aa
1
baccaababccabbaaaaccbacaabbababbabcbcbcbbccaccbccbcabbababcbbccacccccbacaccaaabbaaaacbccbcaaacbaaccccbaccbcbabbbcccaababbaabbcbcacacacaaacbcccaaaabaccccb
7
abacacb...

output:

15 22 39 63 52 
1 10 30 30 39 32 53 53 
153 
24 36 58 94 91 116 127 
12 
53 112 137 226 301 
4 6 12 20 17 16 41 43 63 32 32 32 
3 1 3 1 2 22 32 38 37 33 52 
209 
6 9 43 46 43 55 61 82 90 111 114 117 
150 225 267 279 
3 7 14 29 28 54 52 75 82 98 125 143 
1 4 7 3 15 
1 1 5 7 9 13 20 18 17 31 35 40 
56...

result:

ok 686 numbers

Test #6:

score: 0
Accepted
time: 376ms
memory: 340268kb

input:

1
10
cabaabaabbcabaaaacabbcbabaababaccaccacaacccaaaababccbbcaaccaabcbccccccccbbcbbccbccbbbbccabbbcccbcaabbbbbacabcccbbaaabaaabbcabaaacacaaabbcaacacaabcccbccacababbbacbbacabccbcaabccabaccabbbbaaacacabcbbcacabcabcbaccbacbbbabbabcaaaaccbbacccaccaaccaabccacbbcbbacccacbabbccaacccbcaabacbcaccaacccccaccbab...

output:

111956 186203 269128 465829 642491 700512 757152 903532 903751 1000006 

result:

ok 10 numbers

Test #7:

score: 0
Accepted
time: 269ms
memory: 343076kb

input:

1
1
bccbaaaabcccbbabccbabaccbbbabcabaaaacacbcccacbcbccbcbabbabaacbaacaccbcbacccaaaaacbbbbacbcbabaccbbccbcabbababacaaabacbbcaacccababbcacaacbbaabacabcababaabacabbacabbcbbcabbbcbccaaaabccaaaacccaccbaaccabbccbabbcbbabcacaaacbbcabcbccacbcaabcccaabbcbbabbbbbcabbccaacbabbcccbbcaaacbacabbabacaacacabcbaaccc...

output:

1000000 

result:

ok 1 number(s): "1000000"

Test #8:

score: -100
Time Limit Exceeded

input:

100
2666
g
sn
lat
e
h
ktpo
j
pckf
e
ovn
qe
naudp
ysm
munzjl
usb
zcwgny
eyaafhgtey
kunpaieisjlh
cvorcc
q
se
s
rgg
isby
rlod
f
cyiuczytnk
vgc
vg
fkuk
e
hqg
n
o
du
cdz
kouhklg
fgfhaj
tzu
j
x
k
ju
t
m
qw
v
h
f
y
bhi
y
yx
rem
oo
b
h
dljurs
gxalmvnt
ckjqwc
gupriva
k
k
tosk
mtdn
iyuc
s
o
en
sf
fxygl
cpq
ui...

output:


result: