Submission #1013754

#TimeUsernameProblemLanguageResultExecution timeMemory
1013754hotboy2703Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
1 ms628 KiB
#include <vector> #include<bits/stdc++.h> using namespace std; using ll = int; #define pll pair <ll,ll> #define fi first #define se second #define MP make_pair #define sz(a) (ll((a).size())) #define BIT(mask,i) (((mask) >> (i))&1) #define MASK(i) (1LL << (i)) #include "messy.h" namespace BRUV{ ll n; ll cnt_w,cnt_r; vector <ll> p; void add(ll l,ll r){ if (l == r)return; string s; s.resize(n,'0'); for (ll i = 0;i < l;i ++)s[i] = '1'; for (ll i = r+1;i < n;i ++)s[i] = '1'; ll mid = (l + r) >> 1; for (ll i = l;i <= mid;i ++){ s[i] = '1'; add_element(s); assert(++cnt_w <= 7*64); s[i] = '0'; } add(l,mid); add(mid+1,r); } void solve(ll l,ll r,vector <ll> all_pos){ if (l==r){p[all_pos[0]] = l;return;} string s; s.resize(n,'1'); for (auto x:all_pos)s[x] = '0'; vector <ll> L,R; ll mid = (l + r) >> 1; for (auto x:all_pos){ s[x]='1'; if (check_element(s))L.push_back(x); else R.push_back(x); assert(++cnt_r <= 128*7); s[x]='0'; } solve(l,mid,L); solve(mid+1,r,R); } } std::vector<int> restore_permutation(int N, int w, int r) { using namespace BRUV; n=N; p.resize(n,-1); add(0,n-1); compile_set(); vector <ll> sus(n); iota(sus.begin(),sus.end(),0); solve(0,n-1,sus); return p; }
#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...