Submission #135865

#TimeUsernameProblemLanguageResultExecution timeMemory
135865thebesUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms552 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; string s; void rec(int l,int r){ if(l==r) return; int m = (l+r)/2; for(int i=l;i<=m;i++){ s[i]='1'; add_element(s); s[i]='0'; } for(int i=m+1;i<=r;i++) s[i]='1'; rec(l,m); for(int i=m+1;i<=r;i++) s[i]='0'; for(int i=l;i<=m;i++) s[i]='1'; rec(m+1,r); for(int i=l;i<=m;i++) s[i]='0'; } int *ans; void solve(vector<int> w,int p){ if(w.size()==1) return; vector<int> l, r; for(int i=0;i<w.size();i++){ s[w[i]]='1'; if(!check_element(s)) r.push_back(w[i]); else l.push_back(w[i]); s[w[i]]='0'; } for(auto v : r) ans[v]+=p; for(auto v : l) s[v]='1'; solve(r, p>>1); for(auto v : l) s[v]='0'; for(auto v : r) s[v]='1'; solve(l, p>>1); for(auto v : r) s[v]='0'; } vector<int> restore_permutation(int n, int w, int r){ for(int i=0;i<n;i++) s.push_back('0'); rec(0,n-1); compile_set(); ans = (int*)malloc(n*sizeof(int)); for(int i=0;i<n;i++) ans[i]=0; vector<int> idk; for(int i=0;i<n;i++) idk.push_back(i); solve(idk, n/2); vector<int> res; for(int i=0;i<n;i++) res.push_back(ans[i]); return res; }

Compilation message (stderr)

messy.cpp: In function 'void solve(std::vector<int>, int)':
messy.cpp:27:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.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...