Submission #548956

#TimeUsernameProblemLanguageResultExecution timeMemory
548956HanksburgerUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms468 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; vector<int> useless, ans; bool exist[130]; int N, cnt; string str; void recur1(int L, int R) { if (L==R) return; int mid=(L+R)/2; for (int i=L; i<=mid; i++) { string tmp=str; for (int j=0; j<N; j++) if (j<L || j>R || j==i) tmp[j]='1'; // cout << "add element " << tmp << '\n'; add_element(tmp); } recur1(L, mid); recur1(mid+1, R); } void recur2(vector<int> v) { // cout << "recur2 "; // for (int i=0; i<v.size(); i++) // cout << v[i] << ' '; // cout << '\n'; int sz=v.size(); if (sz==1) { ans[v[0]]=cnt; // cout << "ans " << v[0] << ' ' << cnt << '\n'; cnt++; return; } for (int i=0; i<N; i++) exist[i]=0; for (int i=0; i<sz; i++) exist[v[i]]=1; vector<int> vec1, vec2; for (int i=0; i<sz; i++) { string tmp=str; for (int j=0; j<N; j++) if (!exist[j] || j==v[i]) tmp[j]='1'; // cout << "check element " << tmp << ' ' << check_element(tmp) << '\n'; if (check_element(tmp)) vec1.push_back(v[i]); else vec2.push_back(v[i]); } recur2(vec1); recur2(vec2); } vector<int> restore_permutation(int NN, int WW, int RR) { N=NN; for (int i=0; i<N; i++) str.push_back('0'); recur1(0, N-1); compile_set(); for (int i=0; i<N; i++) { useless.push_back(i); ans.push_back(0); } recur2(useless); 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...