이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN=1e5+10;
void speed()
{
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
}
int n,k;
long long sum=0;
void readFS()
{
long long x;
for(int i=1; i<=n; i++)
{
cin>>x;
sum+=x;
}
}
int a[11];
int d[11][11][11][11][11][11];
/// 0 - not used
/// 1 - yes
/// 2 - no
int cnt[6];
void read()
{
memset(cnt,0,sizeof(cnt));
for(int i=1; i<=n; i++)
{
cin>>a[i];
cnt[a[i]]++;
}
}
int wins(int classes[6],int maxtake)
{
maxtake=min(maxtake,5);
///cout<<classes[1]<<" "<<classes[2]<<" "<<classes[3]<<" "<<classes[4]<<" "<<classes[5]<<" "<<maxtake<<": "<<d[classes[1]][classes[2]][classes[3]][classes[4]][classes[5]][maxtake]<<endl;
if(d[classes[1]][classes[2]][classes[3]][classes[4]][classes[5]][maxtake]!=0)
return d[classes[1]][classes[2]][classes[3]][classes[4]][classes[5]][maxtake];
for(int i=1; i<=5; i++)
{
if(classes[i]>=1)
{
for(int j=1; j<=min(i,maxtake); j++)
{
classes[i]--;
classes[i-j]++;
if(wins(classes,j)==2)
{
classes[i]++;
classes[i-j]--;
d[classes[1]][classes[2]][classes[3]][classes[4]][classes[5]][maxtake]=1;
///cout<<classes[1]<<" "<<classes[2]<<" "<<classes[3]<<" "<<classes[4]<<" "<<classes[5]<<" "<<maxtake<<": "<<d[classes[1]][classes[2]][classes[3]][classes[4]][classes[5]][maxtake]<<endl;
return d[classes[1]][classes[2]][classes[3]][classes[4]][classes[5]][maxtake];
}
else
{
classes[i]++;
classes[i-j]--;
}
}
}
}
d[classes[1]][classes[2]][classes[3]][classes[4]][classes[5]][maxtake]=2;
//cout<<classes[1]<<" "<<classes[2]<<" "<<classes[3]<<" "<<classes[4]<<" "<<classes[5]<<" "<<maxtake<<": "<<d[classes[1]][classes[2]][classes[3]][classes[4]][classes[5]][maxtake]<<endl;
return d[classes[1]][classes[2]][classes[3]][classes[4]][classes[5]][maxtake];
}
int main()
{
speed();
int t;
cin>>t;
while(t--)
{
cin>>n>>k;
if(k==1)
{
sum=0;
readFS();
cout<<sum%2;
}
else
{
read();
//memset(d,0,sizeof(d));
d[0][0][0][0][0][0]=2;
d[0][0][0][0][0][1]=2;
d[0][0][0][0][0][2]=2;
d[0][0][0][0][0][3]=2;
d[0][0][0][0][0][4]=2;
d[0][0][0][0][0][5]=2;
if(wins(cnt,k)==1)cout<<1;
else cout<<0;
}
}
cout<<endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |