# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
954220 | PM1 | Flight to the Ford (BOI22_communication) | C++17 | 193 ms | 352 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "communication.h"
using namespace std;
void encode(int n,int x){
int last=30;
for(int i=29;i>=0;i--){
int z=(x&(1<<i))?1:0;
int a=send(z),b=send(z);
if(a==b){
if(last==30)continue;
z=(x&(1<<last))?1:0;
a=send(z);
b=send(z);
if(a==b)
last=30;
}
else
last=i;
}
}
pair<int,int> decode(int n){
int last=30;
int a,b;
for(int i=29;i>=0;i--){
int x=receive(),y=receive();
a+=(x<<i);
b+=(x<<i);
if(x==y){
if(last==30)continue;
x=receive();
y=receive();
if(x==y){
if((a&(1<<last))==(x<<last))
b=a;
else
a=b;
last=30;
}
else{
if((a&(1<<last))!=(x<<last))
swap(a,b);
}
}
else
last=i;
}
return make_pair(a,b);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |