# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1106478 | Octagons | 메시지 (IOI24_message) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
void send_message(vector<bool> M, vector<bool> C) {
bool op = (1 ^ M.back());
while (M.size() != 1025) {
M.push_back(op);
}
vector<vector<bool>> p(66, vector<bool> (31, 0));
int cur = 0;
for (int i = 0; i < 31; i++) {
if (C[i])continue;
int nxt = 0;
while (C[(i + nxt + 1) % 31]) {
nxt++;
}
p[nxt][i] = true;
for (int j = nxt+1; j < 66; j++) {
p[j][i] = M[cur++];
}
}
for (auto &i : p) {
send_packet(i);
}
}
vector<bool> receive_message(vector<vector<bool>> p) {
int nxt[31], tmp[31];
vector<bool> ret;
vector<int> val;
for (int i = 0; i < 31; i++) {
nxt[i] = 0;
while (nxt[i] < 66 && p[nxt[i]][i] == 0)nxt[i]++;
tmp[i] = nxt[i];
nxt[i] = (i + nxt[i] + 1) % 31;
}
for (int i = 0; i < 31; i++) {
vector<bool> vis(31, false);
int cnt = 0;
int cur = i;
while (!vis[cur]) {
cnt++;
vis[cur] = true;
cur = nxt[cur];
}
if (cnt >= 16) {
for (int j = 0; j < 16; j++) {
val.push_back(cur);
cur = nxt[cur];
}
break;
}
}
sort(val.begin(), val.end());
for (auto &i : val) {
nxt[i] = tmp[i];
for (int j = nxt[i]+1; j < 66 && ret.size() < 1025; j++) {
ret.push_back(p[j][i]);
}
}
bool op = ret.back();
while (ret.back() == op)ret.pop_back();
return ret;
}