Submission #145452

# Submission time Handle Problem Language Result Execution time Memory
145452 2019-08-19T22:54:17 Z qkxwsm Data Transfer (IOI19_transfer) C++14
0 / 100
11 ms 2748 KB
#include "transfer.h"
#include <bits/stdc++.h>

using namespace std;

template<class T, class U>
void ckmin(T &a, U b)
{
	if (a > b) a = b;
}
template<class T, class U>
void ckmax(T &a, U b)
{
	if (a < b) a = b;
}

#define MP make_pair
#define PB push_back
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define FOR(i, a, b) for (auto i = (a); i < (b); i++)
#define FORD(i, a, b) for (auto i = (a) - 1; i >= (b); i--)
#define SZ(x) ((int) ((x).size()))
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vpi;
typedef vector<pll> vpl;


vi get_attachment(vi source)
{
	int n = SZ(source);
	int k = 33 - __builtin_clz(n);
	vi res(k);
	int stor = 0;
	FOR(i, 0, n)
	{
		if (source[i]) stor ^= (i + 1);
	}
	FOR(i, 0, k - 1)
	{
		res[i] = ((stor & (1 << i)) ? 1 : 0);
	}
	res[k - 1] = ((__builtin_popcount(stor)) & 1);
	// cerr << SZ(res) << endl;
	// FOR(i, 0, n + k)
	// {
	// 	cerr <<res[i];
	// }
	// cerr << endl;
	return res;
}

vi retrieve(vi data)
{
	int n = (1 << (31 - __builtin_clz(SZ(data)))) - 1, k = SZ(data) - n;
	// cerr << "N = " << n << " K = " << k << endl;
	// cerr << "DATA HAS\n";
	// FOR(i, 0, n + k)
	// {
	// 	cerr << data[i];
	// }
	// cerr << endl;
	vi res(n);
	FOR(i, 0, n) res[i] = data[i];
	int stor = 0;
	FOR(i, n, n + k - 1)
	{
		stor *= 2; if (data[i - n]) stor++;
	}
	// cerr << "STOR = " << stor << endl;
	if ((__builtin_popcount(stor) & 1) != data[n + k - 1]) return res;
	FOR(i, 0, n) if (data[i]) stor ^= (i + 1);
	if (stor == 0) return res;
	res[stor - 1] ^= 1;
	return res;
	//find the guys that don't match or smth
}
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 900 KB secret mismatch
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 2748 KB secret mismatch
2 Halted 0 ms 0 KB -