Submission #346788

#TimeUsernameProblemLanguageResultExecution timeMemory
346788wwddUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms640 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; void det(int l, int r, int n, vi& pa, vi& res) { if(l == r) { res[pa[0]] = l;return; } string ref(n,'1'); for(int i=0;i<pa.size();i++) { ref[pa[i]] = '0'; } vi ls,rs; for(int i=0;i<pa.size();i++) { string qu = ref; qu[pa[i]] = '1'; if(check_element(qu)) { ls.push_back(pa[i]); } else { rs.push_back(pa[i]); } } int m = (l+r)/2; det(l,m,n,ls,res); det(m+1,r,n,rs,res); } std::vector<int> restore_permutation(int n, int w, int r) { int nb = 0; while((1<<nb) < n) { nb++; } for(int b=1;b<=nb;b++) { int sz = (1<<b); for(int i=0;i<n;i+=sz) { for(int j=0;j<sz/2;j++) { string ad; ad.assign(n,'1'); for(int k=0;k<sz;k++) { ad[i+k] = '0'; } ad[i+j] = '1'; add_element(ad); } } } compile_set(); vi res(n,0); vi par; for(int i=0;i<n;i++) { par.push_back(i); } det(0,n-1,n,par,res); return res; }

Compilation message (stderr)

messy.cpp: In function 'void det(int, int, int, vi&, vi&)':
messy.cpp:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for(int i=0;i<pa.size();i++) {
      |              ~^~~~~~~~~~
messy.cpp:17:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |  for(int i=0;i<pa.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...