Submission #571851

# Submission time Handle Problem Language Result Execution time Memory
571851 2022-06-02T21:58:09 Z RandomLB Data Transfer (IOI19_transfer) C++17
100 / 100
98 ms 2504 KB
#include <bits/stdc++.h>
using namespace std;
 
std::vector<int> get_attachment(std::vector<int> source) {
	std::vector<int> v;
	int x = 0;
	for (int i = 0; i < source.size(); i++)
		if (source[i]) x ^= (i + 1);

	int last = 0;
	if (source.size() < 64) {
		for (int i = 0; i < 6; i++) {
			v.push_back(x & 1);
			if (x & 1) last = 1 - last;
			x >>= 1;
		}
	} else {
		for (int i = 0; i < 8; i++) {
			v.push_back(x & 1);
			if (x & 1) last = 1 - last;
			x >>= 1;
		}
	}
	v.push_back(last);
	return v;
}
 
std::vector<int> retrieve(std::vector<int> v){
    int n = ((int)v.size() < 100? 63 : 255);
    int xr = 0;
    std::vector<int> res;
    for (int i = 0; i < n; i++){
        xr ^= (i+1)*v[i];
        res.push_back(v[i]);
    }
    int check = 0, on = 0;
    for (int i = 0; i < (n==63?6:8); i++){
        if (v[n+i]){
            check ^= (1<<i);
            on ^= 1;
        }
    }
    if (xr != check && on == v.back()) res[(xr^check)-1] ^= 1;
    return res;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:7:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    7 |  for (int i = 0; i < source.size(); i++)
      |                  ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 644 KB Output is correct
2 Correct 4 ms 656 KB Output is correct
3 Correct 4 ms 652 KB Output is correct
4 Correct 4 ms 652 KB Output is correct
5 Correct 4 ms 652 KB Output is correct
6 Correct 4 ms 648 KB Output is correct
7 Correct 4 ms 652 KB Output is correct
8 Correct 4 ms 644 KB Output is correct
9 Correct 4 ms 652 KB Output is correct
10 Correct 3 ms 736 KB Output is correct
11 Correct 4 ms 736 KB Output is correct
12 Correct 4 ms 648 KB Output is correct
13 Correct 4 ms 644 KB Output is correct
14 Correct 4 ms 748 KB Output is correct
15 Correct 4 ms 644 KB Output is correct
16 Correct 4 ms 644 KB Output is correct
17 Correct 4 ms 644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 94 ms 2492 KB Output is correct
2 Correct 94 ms 2500 KB Output is correct
3 Correct 95 ms 2500 KB Output is correct
4 Correct 98 ms 2488 KB Output is correct
5 Correct 94 ms 2488 KB Output is correct
6 Correct 94 ms 2492 KB Output is correct
7 Correct 94 ms 2500 KB Output is correct
8 Correct 93 ms 2500 KB Output is correct
9 Correct 98 ms 2504 KB Output is correct
10 Correct 93 ms 2484 KB Output is correct
11 Correct 96 ms 2504 KB Output is correct
12 Correct 96 ms 2488 KB Output is correct
13 Correct 95 ms 2456 KB Output is correct
14 Correct 95 ms 2488 KB Output is correct
15 Correct 97 ms 2500 KB Output is correct
16 Correct 95 ms 2484 KB Output is correct
17 Correct 95 ms 2500 KB Output is correct
18 Correct 98 ms 2488 KB Output is correct
19 Correct 93 ms 2492 KB Output is correct