제출 #402757

#제출 시각아이디문제언어결과실행 시간메모리
402757blueUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms460 KiB
#include "messy.h" #include <string> #include <vector> using namespace std; int N; vector<int> p_inv; //p[ p_inv[i] ] = i void find_p_inv(int a, int b, vector<int> goodcells) //goodcells contains all the elements i with a <= p_inv[i] <= b { if(a == b) { p_inv[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_inv(a, (a+b)/2, goodcells_1); find_p_inv((a+b)/2+1, b, goodcells_2); } vector<int> restore_permutation(int n, int w, int r) { N = n; p_inv = vector<int>(n, 0); 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); find_p_inv(0, n-1, goodcells); // vector<int> p(n); // for(int i = 0; i < n; i++) // p[p_inv[i]] = i; return p_inv; }
#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...