Submission #211901

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

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: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
1 Incorrect 11 ms 1044 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 3420 KB WA in grader: wrong source retrieval
2 Halted 0 ms 0 KB -