제출 #475964

#제출 시각아이디문제언어결과실행 시간메모리
475964kessido자동 인형 (IOI18_doll)C++17
0 / 100
1 ms204 KiB
#include "doll.h" #include <bits/stdc++.h> const int UNASSINED = 1'000'000'000; const int ROOT = 1'000'000'001; using vi = std::vector<int>; vi create_level(const vi& last_level, vi& X, vi& Y, int& S) { vi new_level; for(size_t i = 0; i < last_level.size(); i++) { if(i+1 < last_level.size()) { X.push_back(last_level[i]); Y.push_back(last_level[i+1]); new_level.push_back(-1 * (++S)); } } return new_level; } int& simulate_untill_next_unassined(int cur_switch, vi& state, vi& X, vi& Y) { while(true) { int idx = -cur_switch - 1; int* ptr = state[idx] ? &X[idx] : &Y[idx]; int& val = *ptr; if(val == UNASSINED) return val; // assert(val < 0); cur_switch = val; } } void create_circuit(int M, std::vector<int> A) { const int N = A.size(); // create tree with N leefs vi X, Y; vi last_level(N, UNASSINED); int S = 0; while(last_level.size() != 1) last_level = create_level(last_level, X, Y, S); int root = -S; for(int i = 0; i < S; i++) if(Y[i]==ROOT) Y[i] = root; vi C(M + 1, root); // for(int i : state) assert(i == 0); // for(int i : X) assert(i != UNASSINED); // for(int i : Y) assert(i != UNASSINED); // assert(X.size() == S); // assert(Y.size() == S); 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...