QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#835565#9921. Yelkrabucup-team5657#WA 401ms209228kbC++202.5kb2024-12-28 12:56:392024-12-28 12:56:39

Judging History

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

  • [2024-12-28 12:56:39]
  • 评测
  • 测评结果:WA
  • 用时:401ms
  • 内存:209228kb
  • [2024-12-28 12:56:39]
  • 提交

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;
#define int long long
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];
signed 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 &x : fact[siz[cur]]) if(!vis[x]) vis[x] = 1, N.emplace_back(x);
			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;
			cout << axor << ' ';
 		}
		cout << '\n';
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 399ms
memory: 209228kb

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: 401ms
memory: 209200kb

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 41 40 43 55 58 54 
95 146 
32 38 39 41 51 79 79 70 64 124 
3 22 47 90 91 117 129 144 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 127 122 
50 

result:

wrong answer 7th numbers differ - expected: '76', found: '66'