MnZn 求助,悬关
查看原帖
MnZn 求助,悬关
371825
SalN楼主2024/4/15 10:10
#include<bits/stdc++.h>
#define int long long
#define up(i,l,r) for(int i=l; i<=r; ++i)
#define dn(i,r,l) for(int i=r; i>=l; --i) 

using namespace std;

const int N=2037;

int n, l, r, x, y, SG[N], cnt[N*N], L[N], R[N];

int Sum() {
	int res=0;
	up(i,1,n) L[i]=R[i]=-1;
	up(l,1,n) if(!cnt[l]&&(l==1||cnt[l-1])) {
		up(r,l,n) if(r==n||cnt[r+1]) {
			up(i,l,r) L[i]=l, R[i]=r;
			res^=SG[r-l+1]; break;
		}
	}
	return res;
}

bool check(int s,int e,int tot) {
	if(L[s]==-1||L[e]==-1||L[s]!=L[e]||R[s]!=R[e]) return 0;
	if(tot^SG[R[s]-L[s]+1]^SG[(s-1)-L[s]+1]^SG[R[e]-(e+1)+1]) return 0;
	up(i,s,e) cnt[i]=1;
	return 1;
}

signed main() {
	cin >> n >> l >> r;
	if(l<r||(l+n)%2==0) {
		if((l+n)%2==1) ++l;
		cout << "First" << endl;
		cout << (n-l)/2+1 << ' ' << l << endl;
		while(cin >> x >> y) {
			if(x<1||y<1) return 0;
			if(x<=n/2) cout << 1+n-x-y+1 << ' ' << y << endl;
			else cout << 1+n-x+y-1 << ' ' << y << endl; 
		}
	}
	up(i,l,n) {
		up(j,0,i-l) cnt[SG[j]^SG[i-j-l]]=1;
		for(int j=0; ; ++j) if(!cnt[j]) { SG[i]=j; break; }
		up(j,0,i-l) cnt[SG[j]^SG[i-j-l]]=0;
	}
	if(!SG[n]) cout << "Second" << endl;
	else {
		cout << "First" << endl;
		up(i,1,n-l+1) if(check(i,i+l-1,SG[n])) { cout << i << ' ' << l << endl; break; }
	}
	while(cin >> x >> y) {
		if(x<1||y<1) return 0;
		up(i,x,x+y-1) cnt[i]=1;
		int tot=Sum();
		up(i,1,n-l+1) if(check(i,i+l-1,tot)) { cout << i << ' ' << l << endl; break; }
	}
	return 0;
}
2024/4/15 10:10
加载中...