Submission #598752

# Submission time Handle Problem Language Result Execution time Memory
598752 2022-07-18T22:19:15 Z farhan132 Data Transfer (IOI19_transfer) C++17
100 / 100
205 ms 2500 KB
#include "transfer.h"
#include <bits/stdc++.h>
 
using namespace std;
 
typedef int ll;
typedef pair<ll , ll> ii;
 
#define ff first
#define ss second
#define pb push_back
#define in insert

std::vector<int> get_attachment(std::vector<int> source) {

	ll n = source.size();
	ll lg = log2(n + 1);
	ll x = 0;
	for(auto u : source) x ^= u;
	source.pb(x);
	vector < ll > ans; ans.pb(x);
	n++;
	for(ll bit = 0; bit < lg; bit++){
		x = 0;
		for(ll i = 0; i < n; i++){
			if((i >> bit)&1) x ^= source[i];
		}
		ans.pb(x);
	}

	return ans;
}

std::vector<int> retrieve(std::vector<int> data) {

	ll n = 256;

	if(data.size() < n) n = 64;
	ll x = 0;
	for(ll i = 0; i < n - 1; i++){
		x ^= data[i];
	}
	if(data[n - 1] != x){
		ll m = data.size();
		ll cur = 0;
		for(ll j = n; j < m; j++){
			ll bit = j - n; x = 0;
			for(ll i = 0; i < n; i++){
				if((i >> bit)&1) x ^= data[i];
			}
			if(x != data[j]) cur |= (1 << bit);
		}
		data[cur] ^= 1;
	}
	while(data.size() > n-1) data.pop_back();

	return data;
}

Compilation message

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:38:17: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   38 |  if(data.size() < n) n = 64;
      |     ~~~~~~~~~~~~^~~
transfer.cpp:55:20: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'll' {aka 'int'} [-Wsign-compare]
   55 |  while(data.size() > n-1) data.pop_back();
      |        ~~~~~~~~~~~~^~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 644 KB Output is correct
2 Correct 3 ms 652 KB Output is correct
3 Correct 5 ms 652 KB Output is correct
4 Correct 3 ms 744 KB Output is correct
5 Correct 3 ms 640 KB Output is correct
6 Correct 4 ms 644 KB Output is correct
7 Correct 3 ms 644 KB Output is correct
8 Correct 5 ms 736 KB Output is correct
9 Correct 4 ms 644 KB Output is correct
10 Correct 3 ms 724 KB Output is correct
11 Correct 5 ms 648 KB Output is correct
12 Correct 5 ms 740 KB Output is correct
13 Correct 4 ms 644 KB Output is correct
14 Correct 3 ms 652 KB Output is correct
15 Correct 4 ms 732 KB Output is correct
16 Correct 4 ms 776 KB Output is correct
17 Correct 4 ms 652 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 197 ms 2496 KB Output is correct
2 Correct 198 ms 2492 KB Output is correct
3 Correct 204 ms 2496 KB Output is correct
4 Correct 197 ms 2488 KB Output is correct
5 Correct 195 ms 2496 KB Output is correct
6 Correct 202 ms 2500 KB Output is correct
7 Correct 193 ms 2496 KB Output is correct
8 Correct 197 ms 2492 KB Output is correct
9 Correct 205 ms 2464 KB Output is correct
10 Correct 201 ms 2460 KB Output is correct
11 Correct 205 ms 2488 KB Output is correct
12 Correct 203 ms 2496 KB Output is correct
13 Correct 197 ms 2496 KB Output is correct
14 Correct 200 ms 2488 KB Output is correct
15 Correct 196 ms 2500 KB Output is correct
16 Correct 195 ms 2496 KB Output is correct
17 Correct 193 ms 2488 KB Output is correct
18 Correct 198 ms 2500 KB Output is correct
19 Correct 196 ms 2452 KB Output is correct