# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
740454 | 2023-05-12T13:42:10 Z | danikoynov | Mechanical Doll (IOI18_doll) | C++14 | 107 ms | 14896 KB |
#include "doll.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; const int maxn = 2e5 + 10; int n, m; vector < int > g[maxn]; vector < int > c, x, y; struct state { int dev, lf_child, rf_child; vector < int > fin; state() { dev = 0; lf_child = rf_child = -1; fin.clear(); } }; void create_node(int v) { if (g[v].size() == 0) return; if (g[v].size() == 1) { c[v] = g[v][0]; return; } int nec = 2, st = 0; while(nec < g[v].size()) nec *= 2, st ++; ///cout << nec << " : " << st << endl; vector < state > gen; int sz = x.size(); state it; it.dev = ++ sz; c[v] = -it.dev; it.fin.push_back(1); gen.push_back(it); for (int step = 0; step < st; step ++) { vector < state > new_gen; for (int i = 0; i < gen.size(); i ++) { state new_state; new_state.dev = ++ sz; gen[i].lf_child = - new_state.dev; for (int cur : gen[i].fin) new_state.fin.push_back(cur * 2 - 1); new_gen.push_back(new_state); new_state = state(); new_state.dev = ++ sz; gen[i].rf_child = - new_state.dev; for (int cur : gen[i].fin) new_state.fin.push_back(cur * 2); new_gen.push_back(new_state); } for (state cur : gen) { x.push_back(cur.lf_child); y.push_back(cur.rf_child); } gen = new_gen; } ///cout << "fine" << endl; for (int i = 0; i < gen.size(); i ++) { ///cout << gen[i].fin.size() << endl; int lf_path = gen[i].fin[0] * 2 - 1, rf_path = gen[i].fin[0] * 2; ///cout << v << " :: " << lf_path << " : " << rf_path << endl; if (lf_path <= g[v].size()) x.push_back(g[v][lf_path - 1]); else x.push_back(- it.dev); if (rf_path <= g[v].size()) y.push_back(g[v][rf_path - 1]); else y.push_back(-it.dev); } } void create_circuit(int M, vector<int> A) { n = A.size(); m = M; c.resize(m + 1); g[0].push_back(A[0]); for (int i = 1; i < A.size(); i ++) { g[A[i - 1]].push_back(A[i]); } g[A.back()].push_back(0); for (int i = 0; i <= m; i ++) { create_node(i); continue; } /**for (int i = 0; i <= m; i ++) cout << c[i] << " "; cout << endl; for (int i = 0; i < x.size(); i ++) cout << x[i] << " " << y[i] << endl;*/ answer(c, x, y); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 25 ms | 8676 KB | Output is correct |
3 | Correct | 22 ms | 8356 KB | Output is correct |
4 | Correct | 3 ms | 4948 KB | Output is correct |
5 | Correct | 12 ms | 6156 KB | Output is correct |
6 | Correct | 33 ms | 10028 KB | Output is correct |
7 | Correct | 2 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 25 ms | 8676 KB | Output is correct |
3 | Correct | 22 ms | 8356 KB | Output is correct |
4 | Correct | 3 ms | 4948 KB | Output is correct |
5 | Correct | 12 ms | 6156 KB | Output is correct |
6 | Correct | 33 ms | 10028 KB | Output is correct |
7 | Correct | 2 ms | 4948 KB | Output is correct |
8 | Correct | 54 ms | 10556 KB | Output is correct |
9 | Correct | 48 ms | 11028 KB | Output is correct |
10 | Correct | 77 ms | 13456 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 2 ms | 4948 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4948 KB | Output is correct |
2 | Correct | 25 ms | 8676 KB | Output is correct |
3 | Correct | 22 ms | 8356 KB | Output is correct |
4 | Correct | 3 ms | 4948 KB | Output is correct |
5 | Correct | 12 ms | 6156 KB | Output is correct |
6 | Correct | 33 ms | 10028 KB | Output is correct |
7 | Correct | 2 ms | 4948 KB | Output is correct |
8 | Correct | 54 ms | 10556 KB | Output is correct |
9 | Correct | 48 ms | 11028 KB | Output is correct |
10 | Correct | 77 ms | 13456 KB | Output is correct |
11 | Correct | 3 ms | 4948 KB | Output is correct |
12 | Correct | 3 ms | 4948 KB | Output is correct |
13 | Correct | 2 ms | 4948 KB | Output is correct |
14 | Incorrect | 107 ms | 14896 KB | wrong motion |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4948 KB | wrong motion |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4948 KB | wrong motion |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 3 ms | 4948 KB | wrong motion |
2 | Halted | 0 ms | 0 KB | - |