# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
88874 | 2018-12-09T17:04:41 Z | sailormoon | Triumphal arch (POI13_luk) | C++14 | 123 ms | 132096 KB |
#include <string> #include <algorithm> #include <iostream> #include <vector> #include <unordered_set> using namespace std; int canHandle(int v, int crs); vector<vector<int>> graph (30000001); // size bool visited[30000001]; int main() { int n, a, b, start = 0, midpoint, end, cities; // n -> towns, a -> from, b -> to scanf("%d", &n); cities = n; // for further usage end = n; // last point n--; while (n--) { scanf("%d %d", &a, &b); graph[a].push_back(b); graph[b].push_back(a); } // binary search for sufficient amount of crews while (start < end) { midpoint = (start + end) / 2; for (int i = 0; i < cities; i++) visited[i] = false; // clear array if (canHandle(1, midpoint) == 0) end = midpoint; else start = ++midpoint; } printf("%d\n", start); return 0; } int canHandle(int v, int crs) { int num_children = 0, need_crews = 0; visited[v] = true; for (int i = 0; i < graph[v].size(); i++) { if (!visited[graph[v][i]]) { num_children++; need_crews += canHandle(graph[v][i], crs); } } return max(0, num_children + need_crews - crs); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 123 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 116 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 110 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 109 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 117 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 106 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 121 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 117 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 110 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 121 ms | 132096 KB | Execution killed with signal 9 (could be triggered by violating memory limits) |
2 | Halted | 0 ms | 0 KB | - |