Submission #426450

#TimeUsernameProblemLanguageResultExecution timeMemory
426450MonchitoMechanical Doll (IOI18_doll)C++14
0 / 100
179 ms332 KiB
#include "doll.h" using namespace std; #define sz(x) (int)x.size() void create_circuit(int M, vector<int> A) { vector<int> C(M+1), X, Y; vector<vector<int>> cnt(M); A.push_back(0); cnt[0].push_back(A[0]); for(int i=0; i<sz(A)-1; i++) cnt[A[i]].push_back(A[i+1]); C[0] = A[0]; for(int i=1; i<M+1; i++) { if(cnt[i].empty()) C[i] = i; } vector<bool> ok(M+1, false); int current_s = -1; for(int i=0; i<sz(A)-1; i++) { if(ok[A[i]]) continue; if(sz(cnt[A[i]]) == 1) C[A[i]] = cnt[A[i]][0]; else { C[A[i]] = current_s; X.push_back(cnt[A[i]][0]); Y.push_back(cnt[A[i]][1]); current_s--; } ok[A[i]] = true; } 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...