WA70pts 究竟是人性的泯灭,还是代码的沦丧?
查看原帖
WA70pts 究竟是人性的泯灭,还是代码的沦丧?
651786
yyc_楼主2023/4/15 11:32
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int maxn = 1e7+10;
char s[maxn];
int p[maxn],pcnt,i,k,l,n;
signed main() {
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>s+1;
	i = 1,l = 1,n = strlen(s+1);
	s[n+1] = 1;
	for(int k = 2;s[k];++k) {
		const int j = k - l;
		if(s[k] == s[j]) continue;
		if(s[k] < s[j]) {
			for(;i<=j;i+=l) p[++pcnt] = i - 1;
			p[++pcnt] = i - 1;
			l = k - i + 1;
		} else l = k - i + 1;
	}
	p[++pcnt] = n;
	pcnt = unique(p + 1, p + pcnt + 1) - p - 1;
	int ans = 0;
	for(int i = 1;i<=pcnt;++i) ans ^= p[i];
	cout<<ans;
}
2023/4/15 11:32
加载中...