Submission #143762

#TimeUsernameProblemLanguageResultExecution timeMemory
143762mahmoudbadawyData Transfer (IOI19_transfer)C++17
100 / 100
75 ms2752 KiB
#include "transfer.h" using namespace std; std::vector<int> get_attachment(std::vector<int> source) { int x=0; vector<int> v; for(int i=0;i<source.size();i++) { if(source[i]==1) x^=(i+1); } int sz=(source.size()==63?6:8),xr=0; while(sz--) { v.push_back(x%2); xr^=x%2; x/=2; } v.push_back(xr); return v; } std::vector<int> retrieve(std::vector<int> data) { int org=data.size()==7+63?63:255; int xr=0; for(int i=org;i<data.size();i++) xr^=data[i]; if(xr) return vector<int>(data.begin(),data.begin()+org); for(int i=data.size()-2;i>=org;i--) { xr*=2; xr+=data[i]; } int x=0; for(int i=0;i<org;i++) if(data[i]) x^=(i+1); if(x!=xr) data[(x^xr)-1]^=1; return vector<int>(data.begin(),data.begin()+org); }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> get_attachment(std::vector<int>)':
transfer.cpp:7:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<source.size();i++)
              ~^~~~~~~~~~~~~~
transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:23:17: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=org;i<data.size();i++) xr^=data[i];
                ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...