# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
642933 | 2022-09-20T20:48:56 Z | danikoynov | Speedrun (RMI21_speedrun) | C++14 | 161 ms | 892 KB |
/** * user: koynov-b21 * fname: Daniel Iliev * lname: Koynov * task: Speedrun * score: 100.0 * date: 2021-12-16 11:34:19.470183 */ #include<bits/stdc++.h> #include "speedrun.h" using namespace std; const int maxn = 1010; vector < int > g[maxn], ch[maxn]; int deg[maxn], par[maxn], nxt[maxn]; vector < int > trav; void assignDfs(int v, int p) { trav.push_back(v); for (int i = 0; i < g[v].size(); i ++) { int u = g[v][i]; if (u == p) continue; par[u] = v; assignDfs(u, v); } } void assignHints(int subtask, int N, int A[], int B[]) { setHintLen(20); for (int i = 1; i < N; i ++) { g[A[i]].push_back(B[i]); g[B[i]].push_back(A[i]); deg[A[i]] ++; deg[B[i]] ++; } assignDfs(1, -1); for (int i = 0; i < trav.size() - 1; i ++) { nxt[trav[i]] = trav[i + 1]; } for (int i = 1; i <= N; i ++) { for (int j = 0; j < 10; j ++) { if ((par[i] & (1 << j)) > 0) setHint(i, j + 1, true); } for (int j = 0; j < 10; j ++) { if ((nxt[i] & (1 << j)) > 0) setHint(i, j + 11, true); } } } void getParent(int ver) { par[ver] = 0; for (int bit = 0; bit < 10; bit ++) if (getHint(bit + 1)) par[ver] += (1 << bit); } void speedrun(int subtask, int N, int start) { int l = getLength(); for (int i = 1; i <= N; i ++) par[i] = 0; int ver = start; while(ver != 1) { getParent(ver); goTo(par[ver]); ver = par[ver]; } int cnt = 1; while(cnt < N) { int nxtn = 0; for (int bit = 0; bit < 10; bit ++) if (getHint(bit + 11)) nxtn += (1 << bit); getParent(nxtn); while(!goTo(nxtn)) { getParent(ver); goTo(par[ver]); ver = par[ver]; } goTo(nxtn); ver = nxtn; cnt ++; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 119 ms | 792 KB | Output is correct |
2 | Correct | 132 ms | 892 KB | Output is correct |
3 | Correct | 105 ms | 748 KB | Output is correct |
4 | Correct | 134 ms | 748 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 95 ms | 760 KB | Output is correct |
2 | Correct | 83 ms | 860 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 126 ms | 800 KB | Output is correct |
2 | Correct | 136 ms | 804 KB | Output is correct |
3 | Correct | 122 ms | 812 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 96 ms | 772 KB | Output is correct |
2 | Correct | 98 ms | 748 KB | Output is correct |
3 | Correct | 120 ms | 684 KB | Output is correct |
4 | Correct | 102 ms | 744 KB | Output is correct |
5 | Correct | 161 ms | 672 KB | Output is correct |
6 | Correct | 122 ms | 740 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 129 ms | 772 KB | Output is correct |
2 | Correct | 97 ms | 776 KB | Output is correct |
3 | Correct | 118 ms | 744 KB | Output is correct |
4 | Correct | 105 ms | 716 KB | Output is correct |
5 | Correct | 84 ms | 804 KB | Output is correct |
6 | Correct | 109 ms | 756 KB | Output is correct |
7 | Correct | 103 ms | 672 KB | Output is correct |