제출 #128529

#제출 시각아이디문제언어결과실행 시간메모리
128529Just_Solve_The_Problem자동 인형 (IOI18_doll)C++11
24 / 100
64 ms6728 KiB
#include <bits/stdc++.h> #include "doll.h" //#include "grader.cpp" using namespace std; const int maxn = (int)1e5 + 7; int sz; void solve4(int M, vector<int> A) { int N = A.size(); vector<int> C(M + 1); vector<int> X, Y; C[0] = A[0]; int tmp = N - 1; while (tmp > 0) { sz++; tmp >>= 1; } if (sz) C[1] = -1; else C[1] = 0; X.resize(sz); Y.resize(sz); tmp = N - 1; for (int i = 1; i <= sz; i++) { if ((tmp >> (sz - i)) & 1) { X[i - 1] = A[0]; } else { X[i - 1] = -1; } Y[i - 1] = ((i == sz) ? 0 : -(i + 1)); } answer(C, X, Y); } int cnt[maxn]; void solve12(int M, vector<int> A) { int N = A.size(); vector<int> C(M + 1); vector<int> X, Y; C[0] = A[0]; for (int i = 0; i < N; i++) { cnt[A[i]]++; int to = ((i + 1 == N) ? 0 : A[i + 1]); if (cnt[A[i]] == 1) { C[A[i]] = -((int)X.size() + 1); X.push_back(C[A[i]]); Y.push_back(to); } else { X[-C[A[i]] - 1] = Y[-C[A[i]] - 1]; Y[-C[A[i]] - 1] = to; } } answer(C, X, Y); } void create_circuit(int M, vector<int> A) { if (M == 1) { solve4(M, A); } else { solve12(M, A); } }
#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...