Submission #467241

#TimeUsernameProblemLanguageResultExecution timeMemory
467241Urvuk3Data Transfer (IOI19_transfer)C++17
100 / 100
72 ms2480 KiB
#include "transfer.h" #include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pll pair<ll,ll> #define pii pair<int,int> #define mid (l+r)/2 #define sz(a) int((a).size()) #define all(a) a.begin(),a.end() #define mod 1000000007LL #define pb push_back #define endl "\n" #define PRINT(x) cerr<<#x<<'-'<<x<<endl<<flush; #define PRINTvec(x) { cerr<<#x<<"-"; for(int i=0;i<sz(x);i++) cerr<<x[i]<<" "; cerr<<endl; } #define getunique(v) {sort(all(v)); v.erase(unique(all(v)), v.end());} #define pb push_back #define pf push_front #define ppf pop_front #define ppb pop_back vector<int> to_bin(ll n,ll k){ vector<int> ret; while(n!=0){ ret.pb(n%2); n/=2; } for(int i=sz(ret);i<k;i++){ ret.pb(0); } return ret; } ll to_int(vector<int> bin){ ll ret=0; for(int i=0;i<sz(bin);i++){ ret+=bin[i]*(1<<i); } return ret; } vector<int> get_attachment(vector<int> source){ ll n=sz(source); ll k=(n==63 ? 6 : 8); ll x=0; ll odd=0; vector<int> append; for(int i=0;i<n;i++){ if(source[i]){ x^=(i+1); } } append=to_bin(x,k); for(int i=0;i<k;i++){ if(append[i]){ odd^=1; } } append.pb(odd); return append; } vector<int> retrieve(vector<int> data){ ll n=(sz(data)==70 ? 63 : 255); ll k=(n==63 ? 6 : 8); ll x=0; ll pravix=0; ll odd=data.back(); vector<int> bitsn(data.begin(),data.begin()+n),bitsk(data.begin()+n,data.end()-1); pravix=to_int(bitsk); for(int i=0;i<n;i++){ if(bitsn[i]){ x^=(i+1); } } if(pravix==x){ return bitsn; } else if((count(all(bitsk),1)&1)==odd){ int idx=pravix^x; bitsn[idx-1]^=1; return bitsn; } else{ return bitsn; } }

Compilation message (stderr)

transfer.cpp: In function 'std::vector<int> retrieve(std::vector<int>)':
transfer.cpp:68:8: warning: unused variable 'k' [-Wunused-variable]
   68 |     ll k=(n==63 ? 6 : 8);
      |        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...