关于刚才ABC 的 G
  • 板块学术版
  • 楼主houzhiyuan
  • 当前回复0
  • 已保存回复0
  • 发布时间2022/6/11 21:43
  • 上次更新2023/10/27 23:30:38
查看原帖
关于刚才ABC 的 G
98490
houzhiyuan楼主2022/6/11 21:43

不知道为啥 WA*20。

思路就是求每堆的 sg,求的方法就直接在前面找一个最小的没有出现过的数。

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=2e5+5;
int n,m,a[N],ans;
map<int,int> mp,sg,vis;
map<int,vector<int> > Mp;
signed main(){
	scanf("%lld%lld",&n,&m);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]),mp[a[i]]^=1;
	for(int i=1,l,r;i<=m;i++){
		scanf("%lld%lld",&l,&r);
		if(!mp.count(l))mp[l]=0;
		if(!mp.count(l-r))mp[l-r]=0;
		Mp[l].push_back(l-r);
	}
	int now=0,las=0;
	for(auto i:mp){
		int x=i.first;
		now+=x-las,las=x;
		sg[x]=now;
		for(int y:Mp[x]){vis[y]--;if(!vis[y])sg[x]=min(sg[x],y);}
		for(int y:Mp[x])vis[y]++;
		vis[sg[x]]++;
		if(mp[x])ans^=sg[x];
	}
	puts(ans?"Takahashi":"Aoki");
}
2022/6/11 21:43
加载中...