Submission #211902

# Submission time Handle Problem Language Result Execution time Memory
211902 2020-03-21T16:20:46 Z MarcoMeijer Data Transfer (IOI19_transfer) C++14
0 / 100
19 ms 4692 KB
#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];
		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,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;
}

Compilation message

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:49:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   if(stepSize > data.size()) {
      ~~~~~~~~~^~~~~~~~~~~~~
transfer.cpp:53: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:38:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 1096 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 19 ms 4692 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -