Submission #23726

#TimeUsernameProblemLanguageResultExecution timeMemory
23726NirjhorUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms512 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; const int N = 135; // [l, r) 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'; // cout << s << endl; add_element(s); s[i] = '0'; } go(n, l, m); go(n, m, r); } vector <int> v; // no contains positions that don't belong to this range void kill (int n, int l, int r, string no) { // cout << l << " " << r << " " << no << endl; 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)) { // cout << "found " << no << endl; 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; } // 10000000 // 01000000 // 00100000 // 00010000 // 10001111 // 01001111 // 11111000 // 11110100 // 10111111 // 11101111 // 11111011 // 11111110

Compilation message (stderr)

messy.cpp: In function 'void go(int, int, int)':
messy.cpp:11:12: 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:58:12: 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...