Submission #401219

#TimeUsernameProblemLanguageResultExecution timeMemory
401219rocks03Data Transfer (IOI19_transfer)C++14
100 / 100
82 ms2544 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pii pair<int, int> #define pll pair<ll, ll> #define ff first #define ss second #define pb push_back #define SZ(x) ((int)(x).size()) #define all(x) x.begin(), x.end() #define debug(x) cout << #x << ": " << x << " " #define nl cout << "\n" #define rep(i, a, b) for(int i = (a); i < (b); i++) #define per(i, a, b) for(int i = (a); i >= (b); i--) mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); vector<int> get_attachment(vector<int> source) { int N = SZ(source), K; if(N == 63) K = 6; else if(N == 255) K = 8; int x = 0, s = 0; rep(i, 0, N){ if(source[i] == 1) x ^= (i + 1), s++; } vector<int> ans; rep(i, 0, K) ans.pb((x >> i) & 1); ans.pb(s % 2); return ans; } vector<int> retrieve(vector<int> data){ int N = SZ(data), K; if(N >= 255) N = 255, K = 8; else N = 63, K = 6; int x = 0, s = 0; rep(i, 0, N){ if(data[i] == 1) x ^= (i + 1), s++; } int x2 = 0; rep(i, 0, K) if(data[N + i] == 1) x2 ^= (1 << i); vector<int> ans; if(x == x2 || s % 2 == data.back()) ans = vector<int>(data.begin(), data.begin() + N); else{ data[(x ^ x2) - 1] ^= 1; ans = vector<int>(data.begin(), data.begin() + N); } return ans; }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:13:41: warning: 'K' may be used uninitialized in this function [-Wmaybe-uninitialized]
   13 | #define rep(i, a, b) for(int i = (a); i < (b); i++)
      |                                         ^
transfer.cpp:18:25: note: 'K' was declared here
   18 |     int N = SZ(source), K;
      |                         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...