Submission #123240

#TimeUsernameProblemLanguageResultExecution timeMemory
123240baqargamUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms508 KiB
#include<bits/stdc++.h> #include "messy.h" using namespace std; string base; vector<int>res; void ddc(int l,int r){ //cout<<l<<" "<<r<<endl; string s=base; int mid=(l+r)/2; for(int i=l;i<r;i++){ s[i]='0'; } for(int i=l;i<mid;i++){ s[i]='1'; // cout<<s<<endl; add_element(s); s[i]='0'; } if(r-l==1)return; ddc(l,mid); ddc(mid,r); } void fnd(int l,int r,vector<int> g){ if(r-l==1) {res[g[0]]=l;return;} vector<int>g1,g2; string s=base; int mid=(l+r)/2; //cout<<l<<" "<<r<<" "<<g.size()<<endl; for(int i=0;i<g.size();i++){ // cout<<g[i]<<" "; s[g[i]]='0'; } //cout<<endl; for(int i=0;i<g.size();i++){ s[g[i]]='1'; int ch=check_element(s); // cout<<"? "<<s<<" "<<g[i]<<" "<<ch<<endl; if(ch) g1.push_back(g[i]); else g2.push_back(g[i]); s[g[i]]='0'; } fnd(l,mid,g1); fnd(mid,r,g2); } vector<int> restore_permutation(int n, int w, int r) { string s=""; vector<int>g; int l=log2(n); int gn=1; for(int i=0;i<n;i++){ base+='1'; g.push_back(i); res.push_back(i); } ddc(0,n); compile_set(); fnd(0,n,g); return res; }

Compilation message (stderr)

messy.cpp: In function 'void fnd(int, int, std::vector<int>)':
messy.cpp:33:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<g.size();i++){
                 ~^~~~~~~~~
messy.cpp:38:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<g.size();i++){
                 ~^~~~~~~~~
messy.cpp: In function 'std::vector<int> restore_permutation(int, int, int)':
messy.cpp:55:9: warning: unused variable 'l' [-Wunused-variable]
     int l=log2(n);
         ^
messy.cpp:56:9: warning: unused variable 'gn' [-Wunused-variable]
     int gn=1;
         ^~
#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...