Submission #1026782

#TimeUsernameProblemLanguageResultExecution timeMemory
1026782boyliguanhanUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms604 KiB
#include <vector> using namespace std; #include "messy.h" vector<int>ans; int n_; void write(int l,int r){ if(l==r)return; string str(n_,'1'); for(int i=l;i<=r;i++) str[i]='0'; for(int i=l;i<=l+r>>1;i++){ str[i]='1'; add_element(str); str[i]='0'; } write(l,l+r>>1); write(l+r+2>>1,r); } void read(int l,int r,vector<int>pos){ if(l==r)return void(ans[pos[0]]=l); string str(n_,'1'); for(auto i:pos) str[i]='0'; vector<int>posl,posr; for(auto i:pos){ str[i]='1'; if(check_element(str)) posl.push_back(i); else posr.push_back(i); str[i]='0'; } read(l,l+r>>1,posl); read(l+r+2>>1,r,posr); } vector<int> restore_permutation(int n, int w, int r) { n_=n; ans.resize(n); write(0,n-1); compile_set(); vector<int>v2(n); for(int i=0;i<n;i++) v2[i]=i; read(0,n-1,v2); return ans; }

Compilation message (stderr)

messy.cpp: In function 'void write(int, int)':
messy.cpp:11:21: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   11 |     for(int i=l;i<=l+r>>1;i++){
      |                    ~^~
messy.cpp:16:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   16 |     write(l,l+r>>1);
      |             ~^~
messy.cpp:17:14: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   17 |     write(l+r+2>>1,r);
      |           ~~~^~
messy.cpp: In function 'void read(int, int, std::vector<int>)':
messy.cpp:32:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   32 |     read(l,l+r>>1,posl);
      |            ~^~
messy.cpp:33:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   33 |     read(l+r+2>>1,r,posr);
      |          ~~~^~
#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...