結果

問題 No.3090 NimNim
ユーザー 沙耶花
提出日時 2025-04-04 22:12:16
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 76 ms / 2,000 ms
コード長 857 bytes
コンパイル時間 4,611 ms
コンパイル使用メモリ 253,708 KB
実行使用メモリ 6,144 KB
最終ジャッジ日時 2025-04-04 22:12:38
合計ジャッジ時間 7,067 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf32 1000000001
#define Inf64 4000000000000000001LL

bool win0(vector<long long> a){
	long long x = 0;
	rep(i,a.size()){
		x ^= a[i];
	}
	return x != 0;
}

bool win1(vector<long long> a){
	sort(a.begin(),a.end());
	if(a.back()==1){
		return a.size()%2==0;
	}
	int c = 0;
	rep(i,a.size()){
		c ^= a[i];
	}
	return c > 0;
}

int main() {
	int n,m;
	cin>>n>>m;
	vector<long long> a(n),b(m);
	rep(i,n)cin>>a[i];
	rep(i,m)cin>>b[i];
	
	bool f0 = win0(a),f1 = win1(a);
	if(f0==f1){
		if(f0)cout<<"First"<<endl;
		else cout<<"Second"<<endl;
		return 0;
	}
	if(f0){
		if(win0(b))cout<<"First"<<endl;
		else cout<<"Second"<<endl;
	}
	else{
		cout<<"First"<<endl;
	}
}
0