Submission #259800

#TimeUsernameProblemLanguageResultExecution timeMemory
259800uacoder123Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
3 ms640 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; #define F first #define S second #define FOR(i,a,b) for (auto i = (a); i <= (b); ++i) #define NFOR(i,a,b) for(auto i = (a); i >= (b); --i) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) #define mp(i,a) make_pair(i,a) #define pb(a) push_back(a) #define bit(x,b) (x&(1LL<<b)) typedef int lli; typedef pair <lli,lli> ii; typedef pair <lli,ii> iii; typedef vector <lli> vi; vi v; void init(int l,int r,int n) { if(l==r) return; int m=(l+r)/2; string s; for(int i=0;i<n;++i) { if(i<l||i>r) s+="1"; else s+="0"; } for(int i=l;i<=m;++i) { s[i]='1'; add_element(s); s[i]='0'; } init(l,m,n); init(m+1,r,n); } void solve(int l,int r,string s,int n) { if(l==r) { for(int i=0;i<n;++i) { if(s[i]=='0') { v[i]=l; break; } } return; } string s1=s,s2=s; for(int i=0;i<n;++i) { if(s[i]!='1') { s[i]='1'; if(check_element(s)) s2[i]='1'; else s1[i]='1'; s[i]='0'; } } int m=(l+r)/2; solve(l,m,s1,n); solve(m+1,r,s2,n); } std::vector<int> restore_permutation(int n, int w, int r) { init(0,n-1,n); compile_set(); string s; for(int i=0;i<n;++i) { v.pb(0); s+="0"; } solve(0,n-1,s,n); return v; }
#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...