Submission #145461

#TimeUsernameProblemLanguageResultExecution timeMemory
145461qkxwsmData Transfer (IOI19_transfer)C++14
100 / 100
96 ms2640 KiB
#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, 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; FORD(i, n + k - 1, n) { stor *= 2; if (data[i]) stor++; } // cerr << "STOR = " << stor << endl; if ((__builtin_popcount(stor) & 1) ^ data[n + k - 1]) return res; // cerr << "OK\n"; FOR(i, 0, n) if (data[i]) stor ^= (i + 1); if (stor == 0) return res; res[stor - 1] ^= 1; // cerr << "RESULT\n"; // FOR(i, 0, n) // { // cerr << res[i]; // } // cerr << endl; return res; //find the guys that don't match or smth }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...