# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
72676 | 2018-08-26T14:07:26 Z | mhnd | Simurgh (IOI17_simurgh) | C++14 | 35 ms | 676 KB |
#include "simurgh.h" using namespace std; const int MAX = 7; int par[MAX]; int find(int v) { return (par[v] == v ? v : par[v] = find(par[v])); } bool merge(int u, int v) { u = find(u); v = find(v); if (u == v) return false; par[u] = v; return true; } vector<int> find_roads(int n, vector<int> u, vector<int> v) { int m = v.size(); for (int mask = 0; mask < (1 << m); mask++) if (__builtin_popcount(mask) == n - 1) { for (int i = 0; i < n; i++) par[i] = i; bool valid = true; vector<int> edges; for (int i = 0; i < m; i++) if ((1 << i) & mask) { edges.push_back(i); valid &= merge(u[i], v[i]); } if (valid && count_common_roads(edges) == n-1) return edges; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 376 KB | correct |
2 | Correct | 31 ms | 480 KB | correct |
3 | Correct | 35 ms | 480 KB | correct |
4 | Correct | 2 ms | 480 KB | correct |
5 | Correct | 2 ms | 480 KB | correct |
6 | Correct | 5 ms | 480 KB | correct |
7 | Correct | 2 ms | 528 KB | correct |
8 | Correct | 2 ms | 528 KB | correct |
9 | Correct | 2 ms | 592 KB | correct |
10 | Correct | 3 ms | 592 KB | correct |
11 | Correct | 2 ms | 592 KB | correct |
12 | Correct | 3 ms | 592 KB | correct |
13 | Correct | 14 ms | 592 KB | correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 376 KB | correct |
2 | Correct | 31 ms | 480 KB | correct |
3 | Correct | 35 ms | 480 KB | correct |
4 | Correct | 2 ms | 480 KB | correct |
5 | Correct | 2 ms | 480 KB | correct |
6 | Correct | 5 ms | 480 KB | correct |
7 | Correct | 2 ms | 528 KB | correct |
8 | Correct | 2 ms | 528 KB | correct |
9 | Correct | 2 ms | 592 KB | correct |
10 | Correct | 3 ms | 592 KB | correct |
11 | Correct | 2 ms | 592 KB | correct |
12 | Correct | 3 ms | 592 KB | correct |
13 | Correct | 14 ms | 592 KB | correct |
14 | Incorrect | 2 ms | 676 KB | WA in grader: NO |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 376 KB | correct |
2 | Correct | 31 ms | 480 KB | correct |
3 | Correct | 35 ms | 480 KB | correct |
4 | Correct | 2 ms | 480 KB | correct |
5 | Correct | 2 ms | 480 KB | correct |
6 | Correct | 5 ms | 480 KB | correct |
7 | Correct | 2 ms | 528 KB | correct |
8 | Correct | 2 ms | 528 KB | correct |
9 | Correct | 2 ms | 592 KB | correct |
10 | Correct | 3 ms | 592 KB | correct |
11 | Correct | 2 ms | 592 KB | correct |
12 | Correct | 3 ms | 592 KB | correct |
13 | Correct | 14 ms | 592 KB | correct |
14 | Incorrect | 2 ms | 676 KB | WA in grader: NO |
15 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 676 KB | correct |
2 | Incorrect | 3 ms | 676 KB | WA in grader: NO |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 376 KB | correct |
2 | Correct | 31 ms | 480 KB | correct |
3 | Correct | 35 ms | 480 KB | correct |
4 | Correct | 2 ms | 480 KB | correct |
5 | Correct | 2 ms | 480 KB | correct |
6 | Correct | 5 ms | 480 KB | correct |
7 | Correct | 2 ms | 528 KB | correct |
8 | Correct | 2 ms | 528 KB | correct |
9 | Correct | 2 ms | 592 KB | correct |
10 | Correct | 3 ms | 592 KB | correct |
11 | Correct | 2 ms | 592 KB | correct |
12 | Correct | 3 ms | 592 KB | correct |
13 | Correct | 14 ms | 592 KB | correct |
14 | Incorrect | 2 ms | 676 KB | WA in grader: NO |
15 | Halted | 0 ms | 0 KB | - |