QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#843881 | #9921. Yelkrab | Zawos | TL | 27ms | 116484kb | C++23 | 1.8kb | 2025-01-05 06:00:51 | 2025-01-05 06:00:52 |
Judging History
answer
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using ld=long double;
using vi=vector<int>;
template<class T> using oset =tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update> ;
//上
ll ans = 0;
struct NOD{
int occ;
int nxt[26];
NOD(){
occ = 1;
fill(begin(nxt),end(nxt),-1);
}
};
void add_string(string& s,vector<NOD>&Trie,vector<vector<ll>> &vals,vector<ll> &dp){
int p1 = 0;
for(int i = 0; i < s.size();i++){
if(Trie[p1].nxt[s[i]-'a'] == -1){
Trie[p1].nxt[s[i]-'a'] = Trie.size();
Trie.emplace_back();
}else{
Trie[Trie[p1].nxt[s[i]-'a']].occ++;
}
p1 = Trie[p1].nxt[s[i]-'a'];
for(int j = 0;j <vals[Trie[p1].occ].size();j++){
ans^=dp[vals[Trie[p1].occ][j]]*vals[Trie[p1].occ][j];
dp[vals[Trie[p1].occ][j]]++;
ans^=dp[vals[Trie[p1].occ][j]]*vals[Trie[p1].occ][j];
}
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin >> t;
while(t--){
int n;
cin >> n;
vector<string> v(n);
vector<NOD> Trie(1);
ll su = 0;
FOR(i,0,n){
cin >> v[i];
su+=v.size();
}
ans = 0;
vector<ll> dp(su+2);
vector<vector<ll>> vals(n+1);
for(int i = 1; i<= n; i++){
for(int j = i; j <= n; j+= i) vals[j].push_back(i);
}
for(int i = 0; i < n; i++){
add_string(v[i],Trie,vals,dp);
cout <<ans <<" ";
}cout<<'\n';
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3856kb
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: 0ms
memory: 3604kb
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: 1ms
memory: 3984kb
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: 1ms
memory: 3672kb
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: 1ms
memory: 3968kb
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: 15ms
memory: 115948kb
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: 27ms
memory: 116484kb
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:
1 3 6 7 8 12 13 17 16 23 21 30 29 39 42 44 57 67 77 78 70 64 95 91 85 86 110 109 127 121 120 101 104 107 109 111 109 148 153 158 157 146 137 180 183 174 160 162 167 164 169 173 189 135 188 191 190 182 176 184 176 182 186 193 216 214 219 228 233 242 238 236 236 210 174 175 173 179 188 177 164 161 166...