Submission #829828

#TimeUsernameProblemLanguageResultExecution timeMemory
829828MrDebooData Transfer (IOI19_transfer)C++17
0 / 100
4 ms2492 KiB
#include "transfer.h" #include "bits/stdc++.h" using namespace std; std::vector<int> get_attachment(std::vector<int> v) { int n=v.size(); vector<int>voc((n==255?8:6)); for(int i=1;i<=n;i++){ for(int w=0;w<8;w++){ if(i&(1<<w))voc[w]^=v[i-1]; } } int g=0; for(auto &i:voc)g^=i; voc.push_back(g); return voc; } std::vector<int> retrieve(std::vector<int> v) { int nn=(v.size()>100?9:7); int n=v.size()-nn; int g=0; for(int i=v.size()-1;i>=v.size()-nn;i--)g^=v[i]; if(g!=v.back()){ for(int i=0;i<nn;i++)v.pop_back(); return v; } vector<int>voc(nn-1); for(int i=1;i<=n;i++){ for(int w=0;w<nn-1;w++){ if(i&(1<<w))voc[w]^=v[i-1]; } } int f=0; for(int i=0;i<nn-1;i++){ if(v[i+n]!=voc[i])f++; } for(int i=0;i<n;i++){ int k=0; for(int w=0;w<nn-1;w++){ if(i&(1<<w)){ if(voc[w]!=v[w+n])k++; } } if(k==f){ v[i]^=1; break; } } for(int i=0;i<nn;i++)v.pop_back(); return v; }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:22:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |  for(int i=v.size()-1;i>=v.size()-nn;i--)g^=v[i];
      |                       ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...