Submission #758046

#TimeUsernameProblemLanguageResultExecution timeMemory
758046alexander707070Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms500 KiB
#include<bits/stdc++.h> #include "messy.h" #define MAXN 10007 using namespace std; int nn; string curr,zero; int perm[MAXN]; bool in[MAXN]; vector<int> ans,v; void question(){ curr=""; for(int i=0;i<nn;i++){ if(in[i])curr+="1"; else curr+="0"; } add_element(curr); } void ask(int l,int r){ if(l==r)return; int mid=(l+r)/2; for(int i=l;i<=mid;i++){ in[i]=true; question(); in[i]=false; } for(int i=mid+1;i<=r;i++)in[i]=true; ask(l,mid); for(int i=mid+1;i<=r;i++)in[i]=false; for(int i=l;i<=mid;i++)in[i]=true; ask(mid+1,r); for(int i=l;i<=mid;i++)in[i]=false; } bool answer(){ curr=""; for(int i=0;i<nn;i++){ if(in[i])curr+="1"; else curr+="0"; } return check_element(curr); } void solve(int l,int r,vector<int> poss){ if(l==r){ perm[poss[0]]=l; return; } vector<int> ll,rr; for(int i=0;i<poss.size();i++){ in[poss[i]]=true; if(answer())ll.push_back(poss[i]); else rr.push_back(poss[i]); in[poss[i]]=false; } int mid=(l+r)/2; for(int i:rr)in[i]=true; solve(l,mid,ll); for(int i:rr)in[i]=false; for(int i:ll)in[i]=true; solve(mid+1,r,rr); for(int i:ll)in[i]=false; } vector<int> restore_permutation(int N, int w, int r){ nn=N; ask(0,nn-1); compile_set(); for(int i=0;i<nn;i++)v.push_back(i); solve(0,nn-1,v); for(int i=0;i<nn;i++){ ans.push_back(perm[i]); } return ans; } /* int main(){ } */

Compilation message (stderr)

messy.cpp: In function 'void solve(int, int, std::vector<int>)':
messy.cpp:55:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |  for(int i=0;i<poss.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...