제출 #299918

#제출 시각아이디문제언어결과실행 시간메모리
299918square1001자동 인형 (IOI18_doll)C++14
47 / 100
242 ms10704 KiB
#include "doll.h" #include <vector> #include <algorithm> using namespace std; void create_circuit(int M, std::vector<int> A) { int N = A.size(); int bits = 1; while((1 << bits) < N) ++bits; vector<int> C(M + 1, -1); C[0] = A[0]; vector<int> X((1 << bits) - 1), Y((1 << bits) - 1); for(int i = 0; i < bits - 1; ++i) { for(int j = (1 << i); j < (2 << i); ++j) { X[j - 1] = -(2 * j); Y[j - 1] = -(2 * j + 1); } } vector<int> perm; for(int i = 1 << bits; i < 2 << bits; ++i) { perm.push_back(i); } sort(perm.begin(), perm.end(), [&](int i, int j) { for(int k = 0; k < bits; ++k) { if(((i >> k) & 1) != ((j >> k) & 1)) { return ((i >> k) & 1) < ((j >> k) & 1); } } return false; }); for(int i = 0; i < 1 << bits; ++i) { int tar = i - ((1 << bits) - N); if(tar < 0) tar = -1; else if(i != ((1 << bits) - 1)) tar = A[tar + 1]; else tar = 0; if(perm[i] % 2 == 0) { X[perm[i] / 2 - 1] = tar; } else { Y[perm[i] / 2 - 1] = tar; } } 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...