Submission #945213

#TimeUsernameProblemLanguageResultExecution timeMemory
945213PenguinsAreCuteUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
1 ms636 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; void preDnc(int n, int l, int r) { string x; for(int i=0;i<n;i++) x+=char((i<l||i>=r)|48); int m = l+r>>1; for(int i=l;i<m;i++) { x[i]='1'; add_element(x); x[i]='0'; } if(r-l>2) { preDnc(n,l,m); preDnc(n,m,r); } } void postDnc(int n, int l, int r, vector<int> &perm) { vector<int> v(begin(perm)+l,begin(perm)+r); string x; for(int i=0;i<n;i++) x+='1'; for(auto i:v) x[i]='0'; int m = l+r>>1; int cur = l, cur2 = m; for(auto i: v) { x[i] = '1'; if(check_element(x)) perm[cur++]=i; else perm[cur2++]=i; x[i] = '0'; } if(r-l>2) { postDnc(n,l,m,perm); postDnc(n,m,r,perm); } } std::vector<int> restore_permutation(int n, int w, int r) { preDnc(n,0,n); compile_set(); vector<int> perm(n); iota(perm.begin(),perm.end(),0); postDnc(n,0,n,perm); vector<int> perm_inv(n); for(int i=0;i<n;i++) perm_inv[perm[i]]=i; return perm_inv; }

Compilation message (stderr)

messy.cpp: In function 'void preDnc(int, int, int)':
messy.cpp:6:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
    6 |  int m = l+r>>1;
      |          ~^~
messy.cpp: In function 'void postDnc(int, int, int, std::vector<int>&)':
messy.cpp:20:11: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   20 |  int m = l+r>>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...