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>
#ifndef SKY
#include<communication.h>
#endif // SKY
using namespace std;
#define N 1000010
#define ll long long
#define ii pair<int,int>
#define fs first
#define sc second
#define pb push_back
#define ld long double
#ifdef SKY
deque<int>dq;
int kt=1;
int send(int s)
{
if(rand()%2==0&&kt==1)
{
kt=0;
dq.push_back((s^1));
return(s^1);
}else
{
kt=1;
dq.push_back(s);
return (s);
}
}
int receive()
{
if(dq.empty())
{
cout<<"NGU VC";
exit(0);
}
int res=dq.front();
dq.pop_front();
return res;
}
#endif // SKY
void encode(int n,int x)
{
if(x==2)
{
for(int i=1;i<=249;i++)
send(0);
}else
{
for(int i=1;i<=249;i++)
send(1);
}
}
pair<int,int>decode(int n)
{
int cnt[2];
for(int i=1;i<=249;i++)
cnt[receive()]++;
if(cnt[0]>cnt[1])
return{2,3};
else return{1,3};
}
#ifdef SKY
int main()
{
freopen("A.inp","r",stdin);
freopen("A.out","w",stdout);
srand(time(0));
int n,x;
cin>>n>>x;
encode(n,x);
ii res=decode(n);
cout<<res.fs<<" "<<res.sc;
return 0;
}
#endif // SKY
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |