Submission #980706

#TimeUsernameProblemLanguageResultExecution timeMemory
980706penguin133Data Transfer (IOI19_transfer)C++17
0 / 100
5 ms2504 KiB
#include <bits/stdc++.h> using namespace std; #include "transfer.h" //#define int long long #define pi pair<int, int> #define pii pair<int, pi> #define fi first #define se second #ifdef _WIN32 #define getchar_unlocked _getchar_nolock #endif mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); std::vector<int> get_attachment(std::vector<int> source) { int n = (int)source.size(); vector <int> ans; for(int i = 0; (1 << i) < n; i++){ int x = 0; for(int j = 0; j < n; j++)if(j >> i & 1)x ^= source[j]; ans.push_back(x ^ source[0]); } ans.push_back(source[0]); return ans; } std::vector<int> retrieve(std::vector<int> data) { int n, num; if((int)data.size() >= 200)n = 255, num = 9; else n = 63, num = 7; if(data[0] != data[(int)data.size() - 1]){ //determine if its 0 or the last guy bool f = 1; for(int i = 0; (1 << i) < n; i++){ int a = 0; for(int j = 0; j < n; j++)if(j >> i & 1)a ^= data[j]; if((a ^ data[0]) != data[(int)data.size() - num + i])f = 0; } if(!f){ data[0] = !data[0]; } vector <int> ans; for(int i = 0; i < n; i++)ans.push_back(data[i]); return ans; } for(int i = 0; i < num - 1; i++){ data[(int)data.size() - num + i] = !data[(int)data.size() - num + i]; bool f = 1; for(int j = 0; (1 << j) < n; j++){ int a = 0; for(int k = 0; k < n; k++)if(k >> j & 1)a ^= data[k]; if(a != (data[(int)data.size() - num + j] ^ data[0]))f = 0; } if(f){ vector <int> ans; for(int i = 0; i < n; i++)ans.push_back(data[i]); return ans; } data[(int)data.size() - num + i] = !data[(int)data.size() - num + i]; } int flipped = 0; for(int i = 0; (1 << i) < n; i++){ int x = 0; for(int j = 0; j < n; j++)if(j >> i & 1)x ^= data[j]; if(x != (data[(int)data.size() - num + i] ^ data[0]))flipped ^= (1 << i); } data[flipped] = !data[flipped]; vector <int> ans; for(int i = 0; i < n; i++)ans.push_back(data[i]); return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...