Submission #999655

# Submission time Handle Problem Language Result Execution time Memory
999655 2024-06-16T02:54:11 Z 12345678 Data Transfer (IOI19_transfer) C++17
100 / 100
44 ms 2520 KB
#include "transfer.h"
#include <bits/stdc++.h>

using namespace std;

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

std::vector<int> retrieve(std::vector<int> data) {
	int sz=(data.size()<100)?6:8, n, sm=0, tmp=0;
	if (sz==6) n=63;
	else n=255;
	for (int i=0; i<n; i++) if (data[i]) sm^=(i+1);
	for (int i=n; i<n+sz; i++) if (data[i]) tmp+=(1<<(i-n));
	if (tmp==sm||(__builtin_popcount(tmp)%2)!=data.back()) return std::vector<int>(data.begin(), data.begin()+n);
	int c=sm^tmp;
	data[c-1]^=1;
	return std::vector<int>(data.begin(), data.begin()+n);
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 788 KB Output is correct
2 Correct 1 ms 800 KB Output is correct
3 Correct 2 ms 792 KB Output is correct
4 Correct 1 ms 800 KB Output is correct
5 Correct 2 ms 800 KB Output is correct
6 Correct 2 ms 888 KB Output is correct
7 Correct 1 ms 792 KB Output is correct
8 Correct 2 ms 800 KB Output is correct
9 Correct 2 ms 796 KB Output is correct
10 Correct 1 ms 792 KB Output is correct
11 Correct 2 ms 796 KB Output is correct
12 Correct 1 ms 800 KB Output is correct
13 Correct 2 ms 792 KB Output is correct
14 Correct 1 ms 792 KB Output is correct
15 Correct 1 ms 792 KB Output is correct
16 Correct 1 ms 804 KB Output is correct
17 Correct 1 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2504 KB Output is correct
2 Correct 32 ms 2512 KB Output is correct
3 Correct 32 ms 2512 KB Output is correct
4 Correct 33 ms 2508 KB Output is correct
5 Correct 32 ms 2516 KB Output is correct
6 Correct 44 ms 2508 KB Output is correct
7 Correct 30 ms 2520 KB Output is correct
8 Correct 28 ms 2508 KB Output is correct
9 Correct 27 ms 2516 KB Output is correct
10 Correct 27 ms 2508 KB Output is correct
11 Correct 26 ms 2516 KB Output is correct
12 Correct 34 ms 2504 KB Output is correct
13 Correct 31 ms 2516 KB Output is correct
14 Correct 31 ms 2516 KB Output is correct
15 Correct 31 ms 2508 KB Output is correct
16 Correct 32 ms 2520 KB Output is correct
17 Correct 32 ms 2512 KB Output is correct
18 Correct 34 ms 2508 KB Output is correct
19 Correct 33 ms 2508 KB Output is correct