제출 #415372

#제출 시각아이디문제언어결과실행 시간메모리
4153722qbingxuan자동 인형 (IOI18_doll)C++17
37 / 100
98 ms11820 KiB
#include "doll.h" #include <bits/stdc++.h> #ifdef local #define debug(x...) qqbx(#x, x) template <typename ...T> void qqbx(const char *s, T ...a) { int cnt = sizeof...(T); ((std::cerr << "\e[1;32m(" << s << ") = ("), ... , (std::cerr << a << (--cnt ? ", " : "\e[0m)\n"))); } #define pary(x...) danb(#x, x) template <typename T> void danb(const char *s, T L, T R) { std::cerr << "\e[1;32m[ " << s << " ] = [ "; for (int f = 0; L != R; ++L) std::cerr << (f++ ? ", " : "") << *L; std::cerr << " ]\e[0m\n"; } #else #define debug(...) ((void)0) #define pary(...) ((void)0) #endif // local #define all(v) begin(v),end(v) using namespace std; const int maxn = 500025; int odd[maxn]; int ls[maxn], rs[maxn]; int leaf[maxn]; int counter = 0; int build(int l, int r, int a, int b) { int cur = counter++; if (l+1 == r) { leaf[cur] = b; debug(cur, leaf[cur]); return cur; } leaf[cur] = -1; int m = l+(r-l)/2; ls[cur] = build(l, m, a*2, b); rs[cur] = build(m, r, a*2, b+a); return cur; } void create_circuit(int M, std::vector<int> A) { int N = A.size(); /* vector<int> cnt(N + 1); for (int i = 0; i < N; i++) cnt[A[i]] += 1; vector<int> tmp; for (int i = 0; i < N; i++) { if (cnt[A[i]] != 1) { tmp.push_back(i); } } tmp.push_back(71222); pary(all(tmp)); */ int S = 0; while ((1<<S) < N/2+1) ++S; debug(S); int H = 1 << S; int root = build(0, H, 1, 0); std::vector<int> C(M + 1, -root-1); std::vector<int> X(counter), Y(counter); debug(H * 2, N); A.resize(H * 2, -root-1); A.back() = 0; for (int i = 0; i < counter; i++) { if (leaf[i] != -1) { X[i] = A[leaf[i]]; Y[i] = A[leaf[i] + H]; } else { X[i] = -ls[i]-1; Y[i] = -rs[i]-1; } } /* int cur = root; do { if (leaf[cur] != -1) { debug(cur, leaf[cur], odd[cur]); // pary(odd, odd+counter); } int nxt = odd[cur] ? rs[cur] : ls[cur]; odd[cur] ^= 1; cur = nxt; } while (accumulate(odd, odd+counter, 0) != 0); */ answer(C, 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...