Submission #395096

#TimeUsernameProblemLanguageResultExecution timeMemory
395096idk321Unscrambling a Messy Bug (IOI16_messy)C++11
100 / 100
3 ms464 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; /* string toBin(int num) { string res; while (num > 0) { res += (num %= 2) - '0'; res /= 2; } return res; }*/ int n; void cons(int a, int b, int pa, int pb, int node) { if (node % 2 == 1) { string cur (n, '1'); for (int i = pa; i<= pb; i++) cur[i] = '0'; for (int i = a; i <= b; i++) { cur[i] = '1'; add_element(cur); //cout << cur << " " << "a" << " " << a << " " << b << " " << pa << " " << pb <<endl; cur[i] = '0'; } } if (a == b) return; int mid =(a + b) / 2; cons(a, mid, a, b, node * 2); cons(mid + 1, b, a, b, node * 2 + 1); } vector<int> solve(vector<int> on) { if (!on.empty()) { /* for (int i : on) cout << i << " "; cout << endl; */ } if (on.size() == 1) return on; string cur (n, '1'); for (int i : on) cur[i] = '0'; vector<int> leftt; vector<int> rightt; for (int i : on) { cur[i] = '1'; //cout << on.size() << " "<< i << " " << cur << endl; if (check_element(cur)) { //cout << "Oj" << endl; rightt.push_back(i); } else leftt.push_back(i); cur[i] = '0'; } leftt = solve(leftt); rightt = solve(rightt); vector<int> res; for (int i : leftt) res.push_back(i); for (int i : rightt) res.push_back(i); return res; } std::vector<int> restore_permutation(int N, int w, int r) { n = N; cons(0, n - 1, 0, n - 1, 0); compile_set(); vector<int> on; for (int i = 0; i < n; i++) on.push_back(i); on = solve(on); vector<int> res(n); for (int i = 0; i < n; i++) res[on[i]] = i; return res; }
#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...