제출 #135487

#제출 시각아이디문제언어결과실행 시간메모리
135487Mahdi_JfriUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
4 ms508 KiB
#include "messy.h" #include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back const int maxn = 2e2 + 20; int res[maxn]; void solve1(int n , int l , int r) { int m = (r - l); string x = string(l , '1') , y = string(n - r , '1'); if(m == 2) { add_element(x + "10" + y); return; } m = (l + r) / 2; for(int i = l; i < m; i++) { string tmp = x + string(r - l , '0') + y; tmp[i] = '1'; add_element(tmp); } solve1(n , l , m); solve1(n , m , r); } bool check(string tmp , int k) { tmp[k] = '1'; bool f = check_element(tmp); return f; } void solve2(int n , int l , int r , vector<int> candid) { string tmp = string(n , '1'); for(auto x : candid) tmp[x] = '0'; assert((int)candid.size() == r - l); if(r - l == 2) { if(!check(tmp , candid[0])) swap(candid[0] , candid[1]); res[l] = candid[0]; res[l + 1] = candid[1]; return; } vector<int> x , y; for(int i = 0; i < r - l; i++) { if(check(tmp , candid[i])) x.pb(candid[i]); else y.pb(candid[i]); } int m = (l + r) / 2; solve2(n , l , m , x); solve2(n , m , r , y); } vector<int> restore_permutation(int n, int w, int r) { solve1(n , 0 , n); compile_set(); vector<int> candid; for(int i = 0; i < n; i++) candid.pb(i); solve2(n , 0 , n , candid); for(int i = 0; i < n; i++) candid[res[i]] = i; return candid; }
#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...