Submission #999655

#TimeUsernameProblemLanguageResultExecution timeMemory
99965512345678Data Transfer (IOI19_transfer)C++17
100 / 100
44 ms2520 KiB
#include "transfer.h" #include <bits/stdc++.h> using namespace std; std::vector<int> get_attachment(std::vector<int> source) { int sz=(source.size()<100)?6:8, sm=0, cnt=0; vector<int> v; for (int i=1; i<(1<<sz); i++) if (source[i-1]) sm^=i; for (int i=0; i<sz; i++) v.push_back((sm>>i)&1), cnt+=((sm>>i)&1); v.push_back(cnt%2); return v; } std::vector<int> retrieve(std::vector<int> data) { int sz=(data.size()<100)?6:8, n, sm=0, tmp=0; if (sz==6) n=63; else n=255; for (int i=0; i<n; i++) if (data[i]) sm^=(i+1); for (int i=n; i<n+sz; i++) if (data[i]) tmp+=(1<<(i-n)); if (tmp==sm||(__builtin_popcount(tmp)%2)!=data.back()) return std::vector<int>(data.begin(), data.begin()+n); int c=sm^tmp; data[c-1]^=1; return std::vector<int>(data.begin(), data.begin()+n); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...