Submission #107215

#TimeUsernameProblemLanguageResultExecution timeMemory
107215popovicirobertUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
11 ms512 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; void divide_add(int l, int r, int n) { if(l == r) { return ; } string str; str.resize(n); for(int i = 0; i < n; i++) { str[i] = '1'; if(l <= i && i <= r) { str[i] = '0'; } } int mid = (l + r) / 2; for(int i = l; i <= mid; i++) { if(i != l) { str[i - 1] = '0'; } str[i] = '1'; add_element(str); } divide_add(l, mid, n); divide_add(mid + 1, r, n); } void divide_check(int l, int r, int n, vector <int> &sol, string &str) { if(l == r) { for(int i = 0; i < n; i++) { if(str[i] == '0') { sol[i] = l; } } return ; } string a, b; a = b = str; for(int i = 0; i < n; i++) { if(str[i] == '0') { str[i] = '1'; if(check_element(str)) { b[i] = '1'; } else { a[i] = '1'; } str[i] = '0'; } } int mid = (l + r) / 2; divide_check(l, mid, n, sol, a); divide_check(mid + 1, r, n, sol, b); } vector<int> restore_permutation(int n, int w, int r) { divide_add(0, n - 1, n); compile_set(); vector <int> sol(n); string str(n, '0'); divide_check(0, n - 1, n, sol, str); return sol; }
#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...