This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define lalala ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//#define ll long long
//#define int long long int
//#define endl '\n'
#define N 2520
#define M 10
//#define big 2147483647
//#define bigg 9223372036854775807
//#define pb push_back
#define p push
//#define ins insert
#define f first
#define s second
map<tuple<int,int,int>,int> mp,iki,git,gittim;
void doldur2(){
int a=0,b=0,c=0;
iki[{a,b,c}]=0;
gittim[{a,b,c}]=1;
queue<tuple<int,int,int>> q;
q.p({1,0,0});
q.p({0,1,0});
q.p({0,0,1});
while(q.size()){
a,b,c;tie(a,b,c)=q.front();q.pop();
if(gittim[{a,b,c}])continue;
gittim[{a,b,c}]=1;
if(gittim[{a+1,b,c}]==0&&a+b+c+1<=10){
q.p({a+1,b,c});
}
if(gittim[{a,b+1,c}]==0&&a+b+c+2<=10){
q.p({a,b+1,c});
}
if(gittim[{a,b,c+1}]==0&&a+b+c+3<=10){
q.p({a,b,c+1});
}
int zero=1,ok=1,yes=1;
if(a){
zero=iki[{a-1,b,c}];
}
if(b){
ok=iki[{a,b-1,c}];
}
if(zero==0||ok==0){
iki[{a,b,c}]=1;
}
}
}
void doldur3(){
int a=0,b=0,c=0;
mp[{a,b,c}]=0;
git[{a,b,c}]=1;
queue<tuple<int,int,int>> q;
q.p({1,0,0});
q.p({0,1,0});
q.p({0,0,1});
while(q.size()){
a,b,c;tie(a,b,c)=q.front();q.pop();
if(git[{a,b,c}])continue;
git[{a,b,c}]=1;
if(git[{a+1,b,c}]==0&&a+b+c+1<=10){
q.p({a+1,b,c});
}
if(git[{a,b+1,c}]==0&&a+b+c+2<=10){
q.p({a,b+1,c});
}
if(git[{a,b,c+1}]==0&&a+b+c+3<=10){
q.p({a,b,c+1});
}
int zero=1,ok=1,yes=1;
if(a){
zero=mp[{a-1,b,c}];
}
if(b){
ok=mp[{a,b-1,c}];
}
if(c){
yes=mp[{a,b,c-1}];
}
if(zero==0||ok==0||yes==0){
mp[{a,b,c}]=1;
}
}
}
signed main(){
lalala;
doldur2();
//cout<<"hello"<<endl;
doldur3();
//cout<<"heello"<<endl;
int test;cin>>test;
while(test--){
int bir=0,ikkk=0,c=0;
int n,k;cin>>n>>k;
int top=0;
for(int i=0;i<n;i++){
int a;cin>>a;
if(a==1)bir++;
if(a==2)ikkk++;
if(a==3)c++;
}
tuple<int,int,int> t={bir,ikkk,c};
int ok=0;
if(k==1){
ok=(k%2);
}
else if(k==2){
ok=iki[t];
}
else ok=mp[t];
cout<<ok;
}
cout<<endl;
}
Compilation message (stderr)
football.cpp: In function 'void doldur2()':
football.cpp:27:3: warning: left operand of comma operator has no effect [-Wunused-value]
27 | a,b,c;tie(a,b,c)=q.front();q.pop();
| ^
football.cpp:27:7: warning: right operand of comma operator has no effect [-Wunused-value]
27 | a,b,c;tie(a,b,c)=q.front();q.pop();
| ^
football.cpp:27:8: warning: right operand of comma operator has no effect [-Wunused-value]
27 | a,b,c;tie(a,b,c)=q.front();q.pop();
| ^
football.cpp:42:19: warning: unused variable 'yes' [-Wunused-variable]
42 | int zero=1,ok=1,yes=1;
| ^~~
football.cpp: In function 'void doldur3()':
football.cpp:64:3: warning: left operand of comma operator has no effect [-Wunused-value]
64 | a,b,c;tie(a,b,c)=q.front();q.pop();
| ^
football.cpp:64:7: warning: right operand of comma operator has no effect [-Wunused-value]
64 | a,b,c;tie(a,b,c)=q.front();q.pop();
| ^
football.cpp:64:8: warning: right operand of comma operator has no effect [-Wunused-value]
64 | a,b,c;tie(a,b,c)=q.front();q.pop();
| ^
football.cpp: In function 'int main()':
football.cpp:106:7: warning: unused variable 'top' [-Wunused-variable]
106 | int top=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... |