Submission #308963

#TimeUsernameProblemLanguageResultExecution timeMemory
308963amunduzbaevUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms640 KiB
#include <bits/stdc++.h> using namespace std; #include "messy.h" //#include "grader.cpp" vector<int>ans; int n1; void add(int l,int r){ string s(n1,'1'); for(int i = l ; i <= r ;i++) s[i]='0'; int m = (l+r)/2; for( int i = l ; i <= m; i++){ s[i]='1'; add_element(s); s[i]='0'; } if(l!=m) add(l, m); if(m+1!=r) add(m+1, r); return; } void check(int l,int r,vector<int> v){ if(l==r){ ans[v[0]] = l; return ; } string s(n1,'1'); for(int i=0;i<v.size() ;i++) s[v[i]]='0'; vector <int> vl, vr; int m=(l+r)/2; for(int i = l ; i <= r; i++){ s[v[i-l]]='1'; if(check_element(s)) vl.push_back(v[i-l]); else vr.push_back(v[i-l]); s[v[i-l]]='0'; } check(l,m,vl); check(m+1,r,vr); } vector<int> restore_permutation(int N, int w, int r) { n1=N; add(0,n1-1); compile_set(); vector<int>v; v.resize(n1); ans.resize(n1); for(int i=0;i<n1;i++) v[i]=i; check(0,n1-1,v); return ans; } /* 4 16 16 1 3 2 0 */

Compilation message (stderr)

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