# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
868044 | TAhmed33 | Flight to the Ford (BOI22_communication) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include <communication.h>
using namespace std;
vector <string> arr = {
"1010",
"1001",
"0101",
"0100",
"0010",
"0001",
"0000"
};
string pp (string a, string b) {
string ret;
for (int i = 0; i < x; i++) {
if (a[i] == b[i]) ret += '0';
else ret += '1';
}
return ret;
}
void encode (int n, int x) {
if (x == 1) {
send(0); send(0); send(0); send(0);
} else if (x == 2) {
send(0); send(0); send(1); send(0);
} else {
send(1); send(1); send(0); send(0);
}
}
pair <int, int> decode (int n) {
string a = "0000", b = "1100", c = "0010";
map <string, vector <int>> x;
for (auto i : arr) x[pp(a, i)].push_back(1);
for (auto i : arr) x[pp(b, i)].push_back(2);
for (auto i : arr) x[pp(b, i)].push_back(3);
string s; for (int i = 0; i < 4; i++) s += (char)(receive() + '0');
if (x[s].size() == 1) {
return {x[s].front(), x[s].front()};
} else {
return {x[s].front(), x[s].back()};
}
}
/*
0000
1100
0010
*/