This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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(bits,20) {
int stepSize = (1<<bits);
bool p=0;
if(stepSize > source.size()) {
RE(i,ans.size()) p ^= ans[i];
ans.pb(p);
return ans;
}
RE(j,source.size()) if((j+1)&stepSize) p^=source[j];
ans.pb(p);
}
}
vi retrieve(vi data) {
int n=63;
if(data.size() > 100) n=255;
int expected=0;
int reality=0;
bool endCorrupt=0;
RE(bits,20) {
int stepSize = (1<<bits);
bool p=0;
if(stepSize > n) {
REP(i,n,data.size()-1) p ^= data[i];
if(p != data.back()) endCorrupt=1;
break;
}
RE(j,n) if((j+1)&stepSize) p^=data[j];
if(p) expected += stepSize;
if(data[n+bits]) reality += stepSize;
}
if(!endCorrupt && reality!=expected) {
int change=reality^expected;
change--;
data[change] ^= 1;
}
while(data.size() > n) data.pop_back();
return data;
}
Compilation message (stderr)
transfer.cpp: In function 'vi get_attachment(vi)':
transfer.cpp:29:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
if(stepSize > source.size()) {
~~~~~~~~~^~~~~~~~~~~~~~~
transfer.cpp: In function 'vi retrieve(vi)':
transfer.cpp:62:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(data.size() > n) data.pop_back();
~~~~~~~~~~~~^~~
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... |