Submission #952384

# Submission time Handle Problem Language Result Execution time Memory
952384 2024-03-23T16:39:26 Z SmuggingSpun Data Transfer (IOI19_transfer) C++14
100 / 100
46 ms 3012 KB
#include "transfer.h"
#include<bits/stdc++.h>
using namespace std;
vector<int>get_attachment(vector<int>source){
	int BIT = (source.size() == 63 ? 6 : 8), x = 0, cnt_1 = 0;
	for(int i = 0; i < source.size(); i++){
		if(source[i] == 1){
			x ^= i + 1;
			cnt_1++;
		}
	}
	vector<int>data;
	for(int i = 0; i < BIT; i++){
		if(1 << i & x){
			data.emplace_back(1);
		}
		else{
			data.emplace_back(0);
		}
	}
	data.emplace_back(cnt_1 & 1);
	return data;
}
vector<int>retrieve(vector<int>data){
	int BIT = (data.size() == 70 ? 6 : 8), n = (BIT == 6 ? 63 : 255), sum_xor = 0, data_xor = 0, cnt_1 = 0;
	vector<int>ans(n);
	for(int i = 0; i < n; i++){
		if(data[i] == 1){
			sum_xor ^= i + 1;
			cnt_1++;
		}
		ans[i] = data[i];
	}
	for(int i = 0; i < BIT; i++){
		if(data[n + i] == 1){
			data_xor |= 1 << i;
		}
	}
	if(data_xor != sum_xor && (cnt_1 & 1) != data.back()){
		ans[(data_xor ^ sum_xor) - 1] ^= 1;
	}
	return ans;
}

Compilation message

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:6:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |  for(int i = 0; i < source.size(); i++){
      |                 ~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 788 KB Output is correct
2 Correct 1 ms 792 KB Output is correct
3 Correct 2 ms 788 KB Output is correct
4 Correct 1 ms 784 KB Output is correct
5 Correct 2 ms 792 KB Output is correct
6 Correct 2 ms 792 KB Output is correct
7 Correct 2 ms 792 KB Output is correct
8 Correct 2 ms 796 KB Output is correct
9 Correct 2 ms 792 KB Output is correct
10 Correct 2 ms 788 KB Output is correct
11 Correct 1 ms 804 KB Output is correct
12 Correct 3 ms 784 KB Output is correct
13 Correct 3 ms 792 KB Output is correct
14 Correct 2 ms 784 KB Output is correct
15 Correct 1 ms 792 KB Output is correct
16 Correct 1 ms 800 KB Output is correct
17 Correct 2 ms 792 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 34 ms 2512 KB Output is correct
2 Correct 35 ms 2512 KB Output is correct
3 Correct 34 ms 2516 KB Output is correct
4 Correct 43 ms 2604 KB Output is correct
5 Correct 42 ms 2504 KB Output is correct
6 Correct 46 ms 2508 KB Output is correct
7 Correct 42 ms 2516 KB Output is correct
8 Correct 37 ms 2516 KB Output is correct
9 Correct 35 ms 2512 KB Output is correct
10 Correct 35 ms 2516 KB Output is correct
11 Correct 35 ms 3012 KB Output is correct
12 Correct 39 ms 2508 KB Output is correct
13 Correct 40 ms 2512 KB Output is correct
14 Correct 40 ms 2512 KB Output is correct
15 Correct 41 ms 2508 KB Output is correct
16 Correct 38 ms 2512 KB Output is correct
17 Correct 42 ms 2508 KB Output is correct
18 Correct 39 ms 2516 KB Output is correct
19 Correct 38 ms 2504 KB Output is correct