# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1093601 | Irate | Data Transfer (IOI19_transfer) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "transfer.h"
using namespace std;
vector<int> get_attachment(vector<int> source) {
int n = (int)source.size();
int XOR = 0, cnt = 0;
for(int i = 0;i < n;++i){
if(source[i]){
XOR ^= (i + 1);
cnt++;
}
}
vector<int>res;
if(n > 100){
for(int i = 0;i < 8;++i){
if(XOR & (1 << i)){
res.push_back(1);
}
else{
res.push_back(0);
}
}
}
else{
for(int i = 0;i < 6;++i){
if(XOR & (1 << i)){
res.push_back(1);
}
else{
res.push_back(0);
}
}
}
res.push_back(cnt & 1);
return res;
}
vector<int> retrieve(vector<int> data) {
int n = (int)source.size();
vector<int>res;
int XOR[2] = {}, par = 0, cnt = 0;
if(n > 100){
for(int i = 0;i < 255;++i){
if(data[i]){
XOR[0] ^= (i + 1);
cnt++;
}
res.push_back(data[i]);
}
for(int i = 0;i < 8;++i){
if(data[255 + i]){
XOR[1] += (1 << i);
}
}
par = data[263];
if(XOR[0] != XOR[1] && cnt % 2 != par){
int pos = XOR[0] ^ XOR[1];
res[pos - 1] ^= 1;
}
}
else{
for(int i = 0;i < 63;++i){
if(data[i]){
XOR[0] ^= (i + 1);
cnt++;
}
res.push_back(data[i]);
}
for(int i = 0;i < 6;++i){
if(data[63 + i]){
XOR[1] += (1 << i);
}
}
par = data[69];
if(XOR[0] != XOR[1] && cnt % 2 != par){
int pos = XOR[0] ^ XOR[1];
res[pos - 1] ^= 1;
}
}
return res;
}