QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#835540 | #9921. Yelkrab | ucup-team5657# | WA | 313ms | 152324kb | C++20 | 2.4kb | 2024-12-28 12:46:33 | 2024-12-28 12:46:34 |
Judging History
answer
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
#define _rep(i_,a_,b_) for(int i_ = (a_); i_ <= (b_); ++i_)
#define mid ((L+R) >> 1)
#define multiCase() int testCnt = in(); _rep(curCase,1,testCnt)
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
using ll = long long;
using pii = pair<int,int>;
int in(void) { int x; cin >> x; return x; } ll inl(void) { ll x; scanf("%lld", &x); return x; }
void out(int x) { printf("%d ", x); } void outln(int x) { printf("%d\n", x); }
void out(ll x) { printf("%lld ", x); } void outln(ll x) { printf("%lld\n", x); }
template<typename T> void chkmax(T &a, const T &b) { a = max(a, b); }
template<typename T> void chkmin(T &a, const T &b) { a = min(a, b); }
const int kN = 1005000, N = 1000000;
int n; string s;
int ch[kN][26], siz[kN], cnt[kN], nc;
vector<int> fact[kN];
int vis[kN], ans[kN];
ll axor;
map<int, int> mem[kN];
int main() {
ios::sync_with_stdio(0), cin.tie(0);
_rep(i,1,N) for(int j = i; j <= N; j += i) ++cnt[j];
_rep(i,1,N) fact[i].reserve(cnt[i]);
_rep(i,1,N) for(int j = i; j <= N; j += i) fact[j].emplace_back(i);
multiCase() {
auto reset = [](int x) {
memset(ch[x], 0, sizeof(ch[x]));
siz[x] = 0, mem[x].clear();
};
n = in(); nc = 1; reset(1);
axor = 0; _rep(i,1,n) ans[i] = 0;
auto modify = [&](int x, int y) {
axor ^= 1ll * ans[x] * x;
ans[x] += y;
axor ^= 1ll * ans[x] * x;
};
_rep(___,1,n) {
cin >> s;
vector<int> N, nod;
int cur = 1; nod.emplace_back(1); ++siz[1];
for(auto c : s) { c -= 'a';
if(!ch[cur][c]) ch[cur][c] = ++nc, reset(nc);
cur = ch[cur][c], ++siz[cur], nod.emplace_back(cur);
for(auto &x : fact[siz[cur]]) if(!vis[x]) vis[x] = 1, N.emplace_back(x);
}
int l = nod.size();
_rep(i,0,l - 2) for(auto &j : N) mem[nod[i]][j] -= mem[nod[i + 1]][j];
for(auto &j : N) vis[j] = 0;
for(int i = l - 1; ~i; --i) {
int u = nod[i];
for(auto &x : fact[siz[u]]) if(!vis[x]) {
vis[x] = 1, ++mem[u][x];
modify(x, i);
}
for(auto &j : N) {
if(i != l - 1) mem[u][j] += mem[nod[i + 1]][j];
while(mem[u][j] * j > siz[u]) modify(j, -i), --mem[u][j];
}
}
for(auto &j : N) vis[j] = 0;
out(axor);
}
puts("");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 308ms
memory: 152252kb
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
Wrong Answer
time: 313ms
memory: 152324kb
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 66 65 73 126 3 1 8 31 47 42 38 63 57 58 95 144 32 34 37 43 49 81 84 88 91 101 3 22 45 93 94 121 128 132 138 40 55 57 59 12 46 49 50 82 101 103 115 117 122 10 45 50 59 80 12 18 27 42 54 72 79 99 105 119 50
result:
wrong answer 7th numbers differ - expected: '76', found: '66'