Submission #694829

#TimeUsernameProblemLanguageResultExecution timeMemory
694829jiahngUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms496 KiB
#include <vector> #include "messy.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int,int> pi; typedef vector <int> vi; typedef vector <pi> vpi; typedef pair<pi, ll> pii; typedef set <ll> si; typedef long double ld; #define f first #define s second #define mp make_pair #define FOR(i,s,e) for(int i=s;i<=int(e);++i) #define DEC(i,s,e) for(int i=s;i>=int(e);--i) #define pb push_back #define all(x) (x).begin(), (x).end() #define lbd(x, y) lower_bound(all(x), y) #define ubd(x, y) upper_bound(all(x), y) #define aFOR(i,x) for (auto i: x) #define mem(x,i) memset(x,i,sizeof x) #define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) #define maxn 200010 #define INF (ll)1e9 #define MOD 1000000007 typedef pair <vi, int> pvi; typedef pair <int,pi> ipi; typedef vector <pii> vpii; int N; vi ans; void dnc(int l,int r){ int m = (l + r) >> 1; if (l == r) return; FOR(k,l,m){ string query = ""; FOR(i,0,N-1){ if (l <= i && i <= r){ if (k == i) query += '1'; else query += '0'; }else query += '1'; } add_element(query); } dnc(l,m); dnc(m+1,r); } void dnc_query(int l,int r, vi &v){ if (l == r){ ans[v[0]] = l; return; } int m = (l + r) >> 1; vi le,ri; aFOR(i, v){ string query = ""; FOR(j,0,N-1) query += '1'; aFOR(j, v) if (j != i) query[j] = '0'; if (check_element(query)) le.pb(i); else ri.pb(i); } dnc_query(l,m,le); dnc_query(m+1,r,ri); } std::vector<int> restore_permutation(int n, int w, int r) { N = n; dnc(0,n-1); vi v; FOR(i,0,n-1) v.pb(i); compile_set(); ans = vi(N); dnc_query(0,n-1,v); return ans; }
#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...