이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "transfer.h"
#include <bits/stdc++.h>
#define bit(v) ( v.size() < 99 ? 6 : 8)
using namespace std;
vector<int> convert(int org, int bits) {
vector<int> res(bits);
for (int i = 0; i < bits; i++)
res[i] = (bool)(org & 1 << i);
return res;
}
int change(vector<int> v) {
int xored = 0;
for (int i = 0; i < v.size(); i++)
if (v[i])
xored ^= i + 1;
return xored;
}
int rev(vector<int> v) {
int n = 0;
for (int i = 0; i < v.size(); i++)
n += v[i] << i;
return n;
}
std::vector<int> get_attachment(std::vector<int> source) {
vector<int> res = convert(change(source), bit(source));
res.push_back(count(source.begin(), source.end(), 1) % 2);
return res;
}
bool corrupt(vector<int> v) {
return vector<int>(v.end() - bit(v), v.end()) != convert(change(vector<int>(v.begin(), v.end() - bit(v))), bit(v));
}
std::vector<int> retrieve(std::vector<int> data) {
vector<int> res = std::vector<int>(data.begin(), data.end() - bit(data) - 1);
int x = count(res.begin(), res.end(), 1);
if (corrupt(std::vector<int>(data.begin(), data.end() - 1))) {
if (x % 2 != data[data.size() - 1]) {
int cb = rev(vector<int>(data.end() - bit(data) - 1, data.end() - 1)) ^ change(vector<int>(data.begin(), data.end() - bit(data) - 1));
res[cb - 1] = !res[cb - 1];
}
}
return res;
}
컴파일 시 표준 에러 (stderr) 메시지
transfer.cpp: In function 'int change(std::vector<int>)':
transfer.cpp:13:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
13 | for (int i = 0; i < v.size(); i++)
| ~~^~~~~~~~~~
transfer.cpp: In function 'int rev(std::vector<int>)':
transfer.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for (int i = 0; i < v.size(); i++)
| ~~^~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |