Submission #1076902

#TimeUsernameProblemLanguageResultExecution timeMemory
1076902belgianbotMechanical Doll (IOI18_doll)C++17
6 / 100
54 ms14900 KiB
#include "doll.h" #include <bits/stdc++.h> #define pb push_back #define fi first #define se second using namespace std; vector<vector<int>> adj; vector<int> C, X, Y; int cnt = -1; void build(int x) { int n = adj[x].size(); if (n == 1) C[x] = adj[x][0]; else if (n) { C[x] = cnt; cnt--; for (int i = n - 1; i > 0; i--) { Y.pb(0); int first = cnt + 1; int time = i - 1; pair<int,int> act = {0, 0}, pre = {1, cnt + 1}; while (time) { if (time % pre.fi == 0) { time -= pre.fi; Y.pb(pre.se); X.pb(cnt); act = {pre.fi, cnt}; pre.fi *= 2; cnt--; } else { time -= act.fi; Y.pb(act.se); X.pb(cnt); pre = {act.fi * 2, act.se}; act.se = cnt; cnt--; } } X.pb(adj[x][n - 1 - i]); auto it = Y.end() + (cnt - first); if (i != 1) { *it = cnt; cnt--; } else *it = adj[x].back(); } } else { C[x] = 0; } } void create_circuit(int M, vector<int> A) { int N = A.size(); A.push_back(0); C.resize(M + 1); adj.resize(M + 1); adj[0].pb(A[0]); C[0] = A[0]; for (int i = 1; i <= N; i++) adj[A[i-1]].pb(A[i]); for (int i = 1; i <= M; i++) build(i); 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...