Submission #59453947


Source Code Expand

#include<bits/stdc++.h>
#include<atcoder/all>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
using namespace atcoder;
typedef long long ll;

int grundy[51][1600];
int W[100005],B[100005];

int mex(set<int>&S){
	for(int c=0;;c++){
		if(S.find(c)==S.end())return c;
	}
}

int dp(int w,int b){
	if(grundy[w][b]>=0)return grundy[w][b];
	if(w==0&&b<=1){
		grundy[w][b]=0;
		return 0;
	}
	set<int>S;
	if(w)S.insert(dp(w-1,b+w));
	for(int k=1;k<=b/2;k++)S.insert(dp(w,b-k));
	return grundy[w][b]=mex(S);
}

int main(){
	rep(i,51)rep(j,1600)grundy[i][j]=-1;

	int n;cin>>n;
	rep(i,n)cin>>W[i];
	rep(i,n)cin>>B[i];
	int G=0;
	rep(i,n){
		G^=dp(W[i],B[i]);
	}
	if(G)cout<<"First"<<endl;
	else cout<<"Second"<<endl;
}

Submission Info

Submission Time
Task 031 - VS AtCoder(★6)
User Rho17
Language C++ 20 (gcc 12.2)
Score 6
Code Size 758 Byte
Status AC
Exec Time 1068 ms
Memory 5080 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 6 / 6
Status
AC × 5
AC × 38
Set Name Test Cases
Sample Sample_1.txt, Sample_2.txt, Sample_3.txt, Sample_4.txt, Sample_5.txt
All Hand_1.txt, Hand_2.txt, Hand_3.txt, Max_Random_01.txt, Max_Random_02.txt, Max_Random_03.txt, Max_Random_04.txt, Max_Random_05.txt, Max_Random_06.txt, Max_Random_07.txt, Max_Random_08.txt, Max_Random_09.txt, Max_Random_10.txt, Random_01.txt, Random_02.txt, Random_03.txt, Random_04.txt, Random_05.txt, Random_06.txt, Random_07.txt, Random_08.txt, Random_09.txt, Random_10.txt, Sample_1.txt, Sample_2.txt, Sample_3.txt, Sample_4.txt, Sample_5.txt, Second_01.txt, Second_02.txt, Second_03.txt, Second_04.txt, Second_05.txt, Second_06.txt, Second_07.txt, Second_08.txt, Second_09.txt, Second_10.txt
Case Name Status Exec Time Memory
Hand_1.txt AC 4 ms 4000 KiB
Hand_2.txt AC 1 ms 3932 KiB
Hand_3.txt AC 1065 ms 3980 KiB
Max_Random_01.txt AC 1061 ms 4860 KiB
Max_Random_02.txt AC 1059 ms 4808 KiB
Max_Random_03.txt AC 1063 ms 4812 KiB
Max_Random_04.txt AC 1067 ms 4724 KiB
Max_Random_05.txt AC 1060 ms 4884 KiB
Max_Random_06.txt AC 1065 ms 4820 KiB
Max_Random_07.txt AC 1062 ms 5080 KiB
Max_Random_08.txt AC 1059 ms 4876 KiB
Max_Random_09.txt AC 1062 ms 4840 KiB
Max_Random_10.txt AC 1068 ms 4936 KiB
Random_01.txt AC 1045 ms 3976 KiB
Random_02.txt AC 1049 ms 4292 KiB
Random_03.txt AC 1048 ms 4132 KiB
Random_04.txt AC 1059 ms 4820 KiB
Random_05.txt AC 1043 ms 3972 KiB
Random_06.txt AC 1058 ms 4512 KiB
Random_07.txt AC 1046 ms 4232 KiB
Random_08.txt AC 1047 ms 4316 KiB
Random_09.txt AC 1056 ms 4672 KiB
Random_10.txt AC 1043 ms 4340 KiB
Sample_1.txt AC 1 ms 3984 KiB
Sample_2.txt AC 1 ms 3936 KiB
Sample_3.txt AC 1 ms 3916 KiB
Sample_4.txt AC 1 ms 3932 KiB
Sample_5.txt AC 1 ms 3868 KiB
Second_01.txt AC 946 ms 4264 KiB
Second_02.txt AC 952 ms 4596 KiB
Second_03.txt AC 951 ms 4332 KiB
Second_04.txt AC 946 ms 4336 KiB
Second_05.txt AC 952 ms 4492 KiB
Second_06.txt AC 955 ms 4916 KiB
Second_07.txt AC 946 ms 4352 KiB
Second_08.txt AC 948 ms 4372 KiB
Second_09.txt AC 953 ms 4488 KiB
Second_10.txt AC 951 ms 4552 KiB