Submission #258879

# Submission time Handle Problem Language Result Execution time Memory
258879 2020-08-06T16:32:06 Z mjkocijan Data Transfer (IOI19_transfer) C++14
100 / 100
447 ms 2680 KB
#include "transfer.h"
#define pb push_back
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
#define X first
#define Y second

vector<int> v;
int k;

std::vector<int> get_attachment(std::vector<int> source) {
	if (source.size() == 63) {
		k = 7;
	}
	else {
		k = 9;
	}
	v = vector<int>(k);
	for (int i = 0; i < source.size(); i++) {
		if (source[i]) {
			for (int j = 0; j < v.size(); j++) {
				if ((i + 1) & (1 << j)) {
					v[j] ^= 1;
				}
			}
			v[k - 1] ^= 1;
		}
	}
	return v;
}

vector<int> ret;

std::vector<int> retrieve(std::vector<int> data) {
	int n;
	if (data.size() == 70) {
		n = 63;
		k = 7;
		v = vector<int>(7);
	} else {
		n = 255;
		k = 9;
		v = vector<int>(9);
	}
	for (int i = 0; i < n; i++) {
		if (data[i]) {
			for (int j = 0; j < k; j++) {
				if ((i + 1) & (1 << j)) {
					v[j] ^= 1;
				}
			}
			v[k - 1] ^= 1;
		}
	}
	int r = 0;
	for (int i = 0; i < k - 1; i++) {
		if (data[n + i] != v[i]) {
			r |= (1 << i);
		}
	}
	if (r && v[k - 1] != data[n + k - 1]) data[r - 1] ^= 1;
	//ret = std::vector<int>(data.begin(), data.end()-k);
	//for (int i: ret) cout << i;cout<<endl;
	//return ret;
	return vector<int>(data.begin(), data.end()-k);
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:21:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int i = 0; i < source.size(); i++) {
                  ~~^~~~~~~~~~~~~~~
transfer.cpp:23:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    for (int j = 0; j < v.size(); j++) {
                    ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 1140 KB Output is correct
2 Correct 4 ms 912 KB Output is correct
3 Correct 4 ms 1280 KB Output is correct
4 Correct 4 ms 1040 KB Output is correct
5 Correct 5 ms 1144 KB Output is correct
6 Correct 5 ms 1148 KB Output is correct
7 Correct 6 ms 1040 KB Output is correct
8 Correct 7 ms 912 KB Output is correct
9 Correct 7 ms 1152 KB Output is correct
10 Correct 7 ms 1144 KB Output is correct
11 Correct 8 ms 912 KB Output is correct
12 Correct 5 ms 1032 KB Output is correct
13 Correct 6 ms 1148 KB Output is correct
14 Correct 6 ms 1040 KB Output is correct
15 Correct 6 ms 1016 KB Output is correct
16 Correct 5 ms 1152 KB Output is correct
17 Correct 6 ms 1140 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 70 ms 2680 KB Output is correct
2 Correct 73 ms 2668 KB Output is correct
3 Correct 76 ms 2628 KB Output is correct
4 Correct 96 ms 2628 KB Output is correct
5 Correct 162 ms 2676 KB Output is correct
6 Correct 245 ms 2668 KB Output is correct
7 Correct 320 ms 2676 KB Output is correct
8 Correct 396 ms 2680 KB Output is correct
9 Correct 442 ms 2660 KB Output is correct
10 Correct 447 ms 2672 KB Output is correct
11 Correct 426 ms 2664 KB Output is correct
12 Correct 260 ms 2628 KB Output is correct
13 Correct 243 ms 2668 KB Output is correct
14 Correct 236 ms 2680 KB Output is correct
15 Correct 250 ms 2628 KB Output is correct
16 Correct 247 ms 2664 KB Output is correct
17 Correct 227 ms 2672 KB Output is correct
18 Correct 234 ms 2500 KB Output is correct
19 Correct 235 ms 2672 KB Output is correct