Submission #402763

#TimeUsernameProblemLanguageResultExecution timeMemory
402763blueUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms492 KiB
#include "messy.h" #include <string> #include <vector> using namespace std; int N; vector<int> p; void find_p(int a, int b, vector<int> goodcells) //goodcells contains all the elements i with a <= p_inv[i] <= b { if(a == b) { p[goodcells[0]] = a; return; } string base_query(N, '1'); for(int g: goodcells) base_query[g] = '0'; vector<int> goodcells_1, goodcells_2; for(int g: goodcells) { string query = base_query; query[g] = '1'; if(check_element(query)) goodcells_1.push_back(g); else goodcells_2.push_back(g); } find_p(a, (a+b)/2, goodcells_1); find_p((a+b)/2+1, b, goodcells_2); } vector<int> restore_permutation(int n, int w, int r) { N = n; for(int g = n; g >= 2; g /= 2) //size of gap { for(int i = 0; i < n; i += g) //starting point of gap { for(int o = 0; o < g/2; o++) { string s(n, '1'); for(int j = i; j < i+g; j++) if(j-i != o) s[j] = '0'; add_element(s); } } } compile_set(); // cerr << n << '\n'; vector<int> goodcells; for(int i = 0; i < n; i++) goodcells.push_back(i); p = vector<int>(n); find_p(0, n-1, goodcells); return p; }
#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...