이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "transfer.h"
#include <bits/stdc++.h>
using namespace std;
//macros
typedef long long ll;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vll;
#define REP(a,b,c) for(int a=int(b); a<int(c); a++)
#define RE(a,c) REP(a,0,c)
#define RE1(a,c) REP(a,1,c+1)
#define REI(a,b,c) REP(a,b,c+1)
#define REV(a,b,c) for(int a=int(c-1); a>=int(b); a--)
#define INF 1e9
#define pb push_back
#define fi first
#define se second
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
vi get_attachment(vi source) {
vi ans;
RE(i,source.size()) ans.pb(source[i]);
RE(bits,10) {
int stepSize = (1<<bits);
bool p=0;
if(stepSize > source.size()) {
REP(i,source.size(),ans.size()) p ^= ans[i];
ans.pb(p);
return ans;
}
for(int j=0; j<source.size(); j+=stepSize) p^=source[j];
}
}
vi retrieve(vi data) {
int n=63;
if(data.size() > 100) n=255;
int expected=0;
int reality=0;
bool endCorrupt=0;
RE(bits,10) {
int stepSize = (1<<bits);
bool p=0;
if(stepSize > data.size()) {
REP(i,n,data.size()-1) p ^= data[i];
if(p != data.back()) endCorrupt=1;
}
for(int j=0; j<data.size(); j+=stepSize) p^=data[j];
if(p) expected += stepSize;
if(data[n+bits]) reality += stepSize;
}
if(!endCorrupt && reality!=expected) {
int change=reality^expected;
data[change] ^= 1;
}
data.resize(n);
return data;
}
컴파일 시 표준 에러 (stderr) 메시지
transfer.cpp: In function 'vi get_attachment(vi)':
transfer.cpp:30:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(stepSize > source.size()) {
~~~~~~~~~^~~~~~~~~~~~~~~
transfer.cpp:35:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j<source.size(); j+=stepSize) p^=source[j];
~^~~~~~~~~~~~~~
transfer.cpp: In function 'vi retrieve(vi)':
transfer.cpp:48:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(stepSize > data.size()) {
~~~~~~~~~^~~~~~~~~~~~~
transfer.cpp:52:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int j=0; j<data.size(); j+=stepSize) p^=data[j];
~^~~~~~~~~~~~
transfer.cpp: In function 'vi get_attachment(vi)':
transfer.cpp:37:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |