제출 #500256

#제출 시각아이디문제언어결과실행 시간메모리
500256sidon자동 인형 (IOI18_doll)C++17
66.60 / 100
120 ms12208 KiB
#include <bits/stdc++.h> using namespace std; #include "doll.h" vector<int> s, x(1<<18), y(1<<18), z(1<<18); int cnt, v = -1, rt = -1, b, n; int dfs(int l, int r) { if(l >= n) return -1; if(r - l < 2) { return 1; } else { int m = (l + r) / 2; int u = cnt++; y[u] = dfs(l, m); x[u] = dfs(m, r); return -u-1; } } void create_circuit(int M, vector<int> A) { s.assign(M+1, -1); A.push_back(0); cnt = b = 0, v = -1, rt = -1, n = size(A); x.assign(2*n, 0); y.assign(2*n, 0); z.assign(2*n, 0); while((1<<b)<n) ++b; dfs(0, 1<<b); for(int &i : A) { int u = 0; while(u >= 0) { z[u] ^= 1; int w = -1-(z[u] ? x[u] : y[u]); if(w < 0) { (z[u] ? x[u] : y[u]) = i; rt = u; u = -1; } else u = w; } } if(n > 2) { x[cnt] = -1-cnt; y[rt] = -1-cnt++; } x.resize(cnt); y.resize(cnt); answer(s, x, y); }
#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...