Submission #554494

#TimeUsernameProblemLanguageResultExecution timeMemory
554494kevinxiehkMechanical Doll (IOI18_doll)C++17
10 / 100
240 ms29488 KiB
#include "doll.h" #include<bits/stdc++.h> #define mp make_pair #define pb emplace_back #define fi first #define se second using namespace std; int cnt = -1; pair<int, int> lr[400005]; map<int, int> hv; int need = 0; int arr[400005]; vector<int> add; int dfs(int lay, int tc, int lef) { if(lay == need) { add.pb(tc + 1); return tc + 1; } int k = (1 << (need - lay - 1)); int thisid = cnt; cnt--; if(lef > k) { lr[-thisid].fi = dfs(lay + 1, tc, k); lr[-thisid].se = dfs(lay + 1, tc + (1 << lay), lef - k); } else { lr[-thisid] = mp(-1, dfs(lay + 1, tc + (1 << lay), lef - k)); } return thisid; } void create_circuit(int m, vector<int> a) { int n = a.size(); vector<int> c(m + 1); c[0] = a[0]; a.pb(0); vector<int> aa; for(int i = 1; i <= n; i++) aa.pb(a[i]); for(int i = 1; i <= m; ++i) { c[i] = -1; } vector<int> l, r; if(n == 1) { l.pb(-1); r.pb(0); answer(c, l, r); return; } while((1 << need) < n) need++; dfs(0, 0, n); for(int i = 1; i < -cnt; i++) hv[-i] = -i; sort(add.begin(), add.end()); for(int i = 0; i < n; i++) hv[add[i]] = aa[i]; // for(int i = 0; i < n; i++) hv[add[i]] = add[i]; for(int i = 1; i < -cnt; i++) { l.pb(hv[lr[i].fi]); r.pb(hv[lr[i].se]); // cerr << -i << ' ' << hv[lr[i].fi] << ' ' << hv[lr[i].se] << '\n'; } answer(c, l, r); return; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...