Submission #703946

# Submission time Handle Problem Language Result Execution time Memory
703946 2023-03-01T04:47:19 Z boyliguanhan Data Transfer (IOI19_transfer) C++17
100 / 100
128 ms 2500 KB
#include "transfer.h"
#include <bits/stdc++.h>
#define bit(v) ( v.size() < 99 ? 6 : 8)
using namespace std;
vector<int> convert(int org, int bits) {
	vector<int> res(bits);
	for (int i = 0; i < bits; i++)
		res[i] = (bool)(org & 1 << i);
	return res;
}
int change(vector<int> v) {
	int xored = 0;
	for (int i = 0; i < v.size(); i++)
		if (v[i])
			xored ^= i + 1;
	return xored;
}
int rev(vector<int> v) {
	int n = 0;
	for (int i = 0; i < v.size(); i++)
		n += v[i] << i;
	return n;
}
std::vector<int> get_attachment(std::vector<int> source) {
	vector<int> res = convert(change(source), bit(source));
	res.push_back(count(source.begin(), source.end(), 1) % 2);
	return res;
}
bool corrupt(vector<int> v) {
	return vector<int>(v.end() - bit(v), v.end()) != convert(change(vector<int>(v.begin(), v.end() - bit(v))), bit(v));
}
std::vector<int> retrieve(std::vector<int> data) {
	vector<int> res = std::vector<int>(data.begin(), data.end() - bit(data) - 1);
	int x = count(res.begin(), res.end(), 1);
	if (corrupt(std::vector<int>(data.begin(), data.end() - 1))) {
		if (x % 2 != data[data.size() - 1]) {
			int cb = rev(vector<int>(data.end() - bit(data) - 1, data.end() - 1)) ^ change(vector<int>(data.begin(), data.end() - bit(data) - 1));
			res[cb - 1] = !res[cb - 1];
		}
	}
	return res;
}

Compilation message

transfer.cpp: In function 'int change(std::vector<int>)':
transfer.cpp:13:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for (int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
transfer.cpp: In function 'int rev(std::vector<int>)':
transfer.cpp:20:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   20 |  for (int i = 0; i < v.size(); i++)
      |                  ~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 652 KB Output is correct
2 Correct 3 ms 652 KB Output is correct
3 Correct 3 ms 652 KB Output is correct
4 Correct 4 ms 740 KB Output is correct
5 Correct 5 ms 644 KB Output is correct
6 Correct 5 ms 728 KB Output is correct
7 Correct 5 ms 740 KB Output is correct
8 Correct 6 ms 740 KB Output is correct
9 Correct 4 ms 728 KB Output is correct
10 Correct 4 ms 652 KB Output is correct
11 Correct 4 ms 648 KB Output is correct
12 Correct 4 ms 652 KB Output is correct
13 Correct 4 ms 736 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 3 ms 676 KB Output is correct
16 Correct 3 ms 652 KB Output is correct
17 Correct 4 ms 652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 116 ms 2484 KB Output is correct
2 Correct 95 ms 2500 KB Output is correct
3 Correct 84 ms 2492 KB Output is correct
4 Correct 94 ms 2496 KB Output is correct
5 Correct 128 ms 2496 KB Output is correct
6 Correct 106 ms 2452 KB Output is correct
7 Correct 97 ms 2488 KB Output is correct
8 Correct 119 ms 2448 KB Output is correct
9 Correct 78 ms 2496 KB Output is correct
10 Correct 76 ms 2488 KB Output is correct
11 Correct 79 ms 2488 KB Output is correct
12 Correct 88 ms 2468 KB Output is correct
13 Correct 88 ms 2488 KB Output is correct
14 Correct 93 ms 2488 KB Output is correct
15 Correct 83 ms 2444 KB Output is correct
16 Correct 91 ms 2488 KB Output is correct
17 Correct 103 ms 2488 KB Output is correct
18 Correct 85 ms 2488 KB Output is correct
19 Correct 82 ms 2456 KB Output is correct