Submission #728889

#TimeUsernameProblemLanguageResultExecution timeMemory
728889nguyentunglamUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#include <vector> #include<bits/stdc++.h> using namespace std; #include "messy.h" vector<int> p; int n; void prepare(int l, int r) { if (l == r) return; int mid = l + r >> 1; string x; for(int i = 0; i < n; i++) x.push_back('1'); for(int i = l; i <= r; i++) x[i] = '0'; for(int i = l; i <= mid; i++) { x[i] = '1'; add_element(x); x[i] = '0'; } prepare(l, mid); prepare(mid + 1, r); } void solve(int l, int r, vector<int> lst) { if (l == r) { p[lst[0]] = l; return; } int mid = l + r >> 1; string x; for(int i = 0; i < n; i++) x.push_back('1'); for(int &j : lst) x[j] = '0'; vector<int> Left, Right; for(int &j : lst) { x[j] = '1'; if (check_element(x)) Left.push_back(j); else Right.push_back(j); x[j] = '0'; } solve(l, mid, Left); solve(mid + 1, r, Right); } std::vector<int> restore_permutation(int _n, int w, int r) { n = _n; p.resize(n); prepare(0, n - 1); compile_set(); vector<int> init; for(int i = 0; i < n; i++) init.push_back(i); solve(0, n - 1, init); return p; }

Compilation message (stderr)

messy.cpp: In function 'void prepare(int, int)':
messy.cpp:12:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   12 |     int mid = l + r >> 1;
      |               ~~^~~
messy.cpp: In function 'void solve(int, int, std::vector<int>)':
messy.cpp:30:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |     int mid = 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...