Submission #143762

# Submission time Handle Problem Language Result Execution time Memory
143762 2019-08-15T03:42:40 Z mahmoudbadawy Data Transfer (IOI19_transfer) C++17
100 / 100
75 ms 2752 KB
#include "transfer.h"
using namespace std;

std::vector<int> get_attachment(std::vector<int> source) {
	int x=0;
	vector<int> v;
	for(int i=0;i<source.size();i++)
	{
		if(source[i]==1) x^=(i+1);
	}
	int sz=(source.size()==63?6:8),xr=0;
	while(sz--)
	{
		v.push_back(x%2); xr^=x%2; x/=2;
	}
	v.push_back(xr);
	return v;
}

std::vector<int> retrieve(std::vector<int> data) {
	int org=data.size()==7+63?63:255;
	int xr=0;
	for(int i=org;i<data.size();i++) xr^=data[i];
	if(xr) return vector<int>(data.begin(),data.begin()+org);
	for(int i=data.size()-2;i>=org;i--)
	{
		xr*=2; xr+=data[i];
	}
	int x=0;
	for(int i=0;i<org;i++)
		if(data[i]) x^=(i+1);
	if(x!=xr) data[(x^xr)-1]^=1;
	return vector<int>(data.begin(),data.begin()+org);
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:7:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<source.size();i++)
              ~^~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:23:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=org;i<data.size();i++) xr^=data[i];
                ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 888 KB Output is correct
2 Correct 6 ms 1016 KB Output is correct
3 Correct 6 ms 888 KB Output is correct
4 Correct 6 ms 1124 KB Output is correct
5 Correct 6 ms 888 KB Output is correct
6 Correct 6 ms 1016 KB Output is correct
7 Correct 6 ms 896 KB Output is correct
8 Correct 7 ms 1028 KB Output is correct
9 Correct 7 ms 1128 KB Output is correct
10 Correct 6 ms 976 KB Output is correct
11 Correct 6 ms 896 KB Output is correct
12 Correct 7 ms 900 KB Output is correct
13 Correct 7 ms 1024 KB Output is correct
14 Correct 6 ms 972 KB Output is correct
15 Correct 7 ms 1016 KB Output is correct
16 Correct 6 ms 888 KB Output is correct
17 Correct 6 ms 1024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 63 ms 2612 KB Output is correct
2 Correct 66 ms 2736 KB Output is correct
3 Correct 65 ms 2612 KB Output is correct
4 Correct 71 ms 2612 KB Output is correct
5 Correct 73 ms 2476 KB Output is correct
6 Correct 75 ms 2476 KB Output is correct
7 Correct 74 ms 2612 KB Output is correct
8 Correct 69 ms 2480 KB Output is correct
9 Correct 61 ms 2608 KB Output is correct
10 Correct 60 ms 2748 KB Output is correct
11 Correct 59 ms 2496 KB Output is correct
12 Correct 71 ms 2752 KB Output is correct
13 Correct 72 ms 2600 KB Output is correct
14 Correct 71 ms 2648 KB Output is correct
15 Correct 69 ms 2612 KB Output is correct
16 Correct 68 ms 2624 KB Output is correct
17 Correct 72 ms 2636 KB Output is correct
18 Correct 67 ms 2612 KB Output is correct
19 Correct 64 ms 2480 KB Output is correct