Submission #445593

#TimeUsernameProblemLanguageResultExecution timeMemory
445593FEDIKUSUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms460 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; typedef string str; void dodaj(int n,int l,int r){ if(l==r) return; str s; for(int i=0;i<n;i++){ if(l<=i && i<=r) s+='0'; else s+='1'; } int mid=l+(r-l)/2; for(int i=l;i<=mid;i++){ s[i]='1'; add_element(s); s[i]='0'; } dodaj(n,l,mid); dodaj(n,mid+1,r); } vector<int> spoji(vector<int> a,vector<int> b){ for(int i=0;i<b.size();i++) a.push_back(b[i]); return a; } vector<int> resi(int n,int l,int r,vector<int> &gde){ if(l==r) return gde; vector<int> gde1; vector<int> gde2; str s; for(int i=0;i<n;i++){ if(binary_search(gde.begin(),gde.end(),i)) s+='0'; else s+='1'; } for(int i:gde){ s[i]='1'; if(check_element(s)) gde1.push_back(i); else gde2.push_back(i); s[i]='0'; } int mid=l+(r-l)/2; return spoji(resi(n,l,mid,gde1),resi(n,mid+1,r,gde2)); } vector<int> shiftuj(vector<int> a){ vector<int> ret(a.size()); for(int i=0;i<a.size();i++){ ret[a[i]]=i; } return ret; } std::vector<int> restore_permutation(int n, int w, int r) { dodaj(n,0,n-1); compile_set(); vector<int> gde; for(int i=0;i<n;i++) gde.push_back(i); return shiftuj(resi(n,0,n-1,gde)); } /* 4 16 16 2 1 3 0 */

Compilation message (stderr)

messy.cpp: In function 'std::vector<int> spoji(std::vector<int>, std::vector<int>)':
messy.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<b.size();i++) a.push_back(b[i]);
      |                 ~^~~~~~~~~
messy.cpp: In function 'std::vector<int> shiftuj(std::vector<int>)':
messy.cpp:52:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     for(int i=0;i<a.size();i++){
      |                 ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...