이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include"communication.h"
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair<int,int>
#define fi first
#define se second
#define endl '\n'
#define puf push_front
#define pof pop_front
#define pub push_back
#define pob pop_back
#define lb lower_bound
#define ub upper_bound
#define rep(x,s,e) for (int x=(s)-((s)>(e));x!=(e)-((s)>(e));((s)<(e))?x++:x--)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int) (x).size()
mt19937 rng(chrono::system_clock::now().time_since_epoch().count());
void encode(signed N, signed X) {
int t;
X--;
if (X==2){
send(1);
send(1);
send(0);
}
else if (X==0){
t=send(0);
if (t==1) send(1);
t=send(0);
if (t==1) send(1);
send(1);
send(1);
send(0);
}
else{
t=send(0);
if (t==1) send(0);
t=send(0);
if (t==1) send(0);
t=send(0);
if (t==1) send(1);
t=send(0);
if (t==1) send(1);
send(1);
send(1);
send(0);
}
}
std::pair<signed, signed> decode(signed N) {
int t;
int curr=0;
while (true){
t=receive();
if (t==0) curr++;
else break;
}
curr=(curr/2+receive())%3;
//cout<<"debug: "<<curr<<endl;
//cout<<(curr+1)%3+1<<" "<<(curr+2)%3+1<<endl;
return {(curr+1)%3+1,(curr+2)%3+1};
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |