Submission #1082933

#TimeUsernameProblemLanguageResultExecution timeMemory
1082933MMihalevUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms604 KiB
#include<iostream> #include<vector> #include<algorithm> #include<set> #include "messy.h" using namespace std; int N; vector<int>pe; void recadd(int l,int r) { if(l==r)return; string s; s.resize(N); for(int i=0;i<N;i++)s[i]='1'; for(int i=l;i<=r;i++)s[i]='0'; int mid=(l+r)/2; for(int i=l;i<=mid;i++) { s[i]='1'; add_element(s); s[i]='0'; } recadd(l,mid); recadd(mid+1,r); } void recask(int l,int r,set<int>se) { if(l==r) { int pos=(*(se.begin())); pe[pos]=l; return; } string s; set<int>other1,other2; s.resize(N); for(int i=0;i<N;i++)s[i]='1'; for(int i:se)s[i]='0'; for(int i:se) { s[i]='1'; if(check_element(s))other1.insert(i); s[i]='0'; } for(int i:se) { if(other1.count(i))continue; other2.insert(i); } int mid=(l+r)/2; recask(l,mid,other1); recask(mid+1,r,other2); } vector<int> restore_permutation(int Ne, int W, int R) { N=Ne; pe.resize(N); recadd(0,N-1); compile_set(); set<int>ss; for(int i=0;i<N;i++)ss.insert(i); recask(0,N-1,ss); return pe; }
#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...