Submission #116309

#TimeUsernameProblemLanguageResultExecution timeMemory
116309ojuztest3141411Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms640 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; void go (int n, int l, int r) { if (l + 1 == r) return; int m = l + r >> 1; string s = ""; for (int i = 0; i < n; ++i) { s += '1'; } for (int i = l; i < r; ++i) { s[i] = '0'; } for (int i = l; i < m; ++i) { s[i] = '1'; add_element(s); s[i] = '0'; } go(n, l, m); go(n, m, r); } vector <int> v; void kill (int n, int l, int r, string no) { if (l + 1 == r) { for (int i = 0; i < n; ++i) { if (no[i] == '0') { v[i] = l; break; } } return; } string x = no, y = ""; for (int i = 0; i < n; ++i) { y += '1'; } for (int i = 0; i < n; ++i) { if (no[i] == '0') { no[i] = '1'; if (check_element(no)) { x[i] = '1'; y[i] = '0'; } no[i] = '0'; } } int m = l + r >> 1; kill(n, l, m, y); kill(n, m, r, x); } vector <int> restore_permutation (int n, int w, int r) { go(n, 0, n); compile_set(); v.resize(n); string s = ""; for (int i = 0; i < n; ++i) { s += '0'; } kill(n, 0, n, s); return v; }

Compilation message (stderr)

messy.cpp: In function 'void go(int, int, int)':
messy.cpp:8:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   int m = l + r >> 1;
           ~~^~~
messy.cpp: In function 'void kill(int, int, int, std::__cxx11::string)':
messy.cpp:51:13: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   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...