QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#181664 | #6642. (1, 2) Nim | ucup-team134# | WA | 3ms | 3824kb | C++14 | 2.0kb | 2023-09-16 21:58:19 | 2023-09-16 21:58:19 |
Judging History
answer
#include<bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define ll long long
using namespace std;
typedef pair<int,int> pii;
const int mod=998244353;
inline int add(int x,int y){int ret=x+y;if(ret>=mod)ret-=mod;return ret;}
inline int sub(int x,int y){int ret=x-y;if(ret<0)ret+=mod;return ret;}
inline int mul(int x,int y){return ((ll)x*y)%mod;}
inline int step(int base,int pw){int ret=1;while(pw){if(pw&1)ret=mul(ret,base);base=mul(base,base);pw>>=1;}return ret;}
inline int invv(int x){return step(x,mod-2);}
const int maxn=2e5+10;
int main(){
///freopen("test.txt","r",stdin);
int t;
scanf("%d",&t);
while(t--){
int n;
scanf("%d",&n);
int cnt1=0;
int cnt2=0;
for(int i=1;i<=n;i++){
int a;
scanf("%d",&a);
if(a>1)cnt2++;
else cnt1++;
}
/*if(n==1){
printf("Sprague\n");
continue;
}
if(n==2){
printf("Grundy\n");
continue;
}*/
int rez=0;
int cp=0;
while(1){
if(cnt1==0){
if(cnt2==1 && cp==0)rez=0;
else rez=1;
break;
}
if(cnt2==0){
if(cp==0){
if(cnt1%3==1)rez=0;
else rez=1;
break;
}
else{
if(cnt1-2<=0){
rez=1;
break;
}
cnt1-=2;
if(cnt1%3==1)rez=0;
else rez=1;
break;
}
}
if(cp==0){
cnt2--;
cnt1++;
}
else{
cnt1-=min(2,cnt1);
}
cp^=1;
}
if(rez==0)printf("Sprague\n");
else printf("Grundy\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3824kb
input:
3 2 1 2 1 5 4 1 7 2 9
output:
Grundy Sprague Grundy
result:
ok 3 lines
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 3776kb
input:
11337 9 4 1 2 3 2 4 3 2 3 10 1 7 1 5 1 2 2 2 1 3 9 1 3 7 3 3 1 1 3 2 12 1 1 2 4 1 2 2 4 2 2 1 4 15 1 3 4 3 1 2 1 4 1 1 1 1 1 1 1 8 3 3 2 2 3 9 1 2 10 2 2 2 2 1 5 1 2 7 2 10 2 2 2 3 2 2 3 5 2 2 7 2 2 6 2 2 3 5 10 1 1 1 3 1 1 1 5 1 1 8 2 2 2 2 5 2 10 1 5 3 10 1 3 1 8 3 4 2 2 1 1 11 1 6 6 4 8 2 4 2 10 ...
output:
Grundy Grundy Grundy Grundy Grundy Grundy Grundy Grundy Grundy Grundy Grundy Sprague Grundy Grundy Sprague Grundy Grundy Sprague Grundy Sprague Grundy Grundy Grundy Grundy Sprague Grundy Sprague Grundy Grundy Grundy Grundy Sprague Grundy Grundy Sprague Grundy Grundy Grundy Grundy Grundy Grundy Grund...
result:
wrong answer 12th lines differ - expected: 'Grundy', found: 'Sprague'