# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548822 | 2022-04-14T12:28:10 Z | usukhbaatar | City Mapping (NOI18_citymapping) | C++14 | 178 ms | 12852 KB |
#include "citymapping.h" #include <vector> #include <queue> #include <algorithm> using namespace std; int p[100001]; int _find(int x) { if (p[x] == x) return x; return p[x] = _find(p[x]); } bool _union(int x, int y) { x = _find(x); y = _find(y); if (x == y) return false; p[x] = y; return true; } void find_roads(int N, int Q, int A[], int B[], int W[]) { vector<pair<int, pair<int, int>>> e; int xx = 0; for (int i = 0; i < N; i++) { p[i] == i; } for (int i = 1; i <= N; i++) { for (int j = i + 1; j <= N; j++) { int temp = get_distance(i, j); if (temp == 1) { if (_union(i, j)) { A[xx] = i; B[xx] = j; W[xx] = 1; xx++; } } else { e.push_back({temp, {i, j}}); e.push_back({temp, {j, i}}); } } } if (xx == N - 1) return; sort(e.begin(), e.end()); for (int i = 0; i < e.size(); i++) { int u = e[i].second.first; int v = e[i].second.second; if (_union(u, v)) { A[xx] = u; A[xx] = v; W[xx] = e[i].first; } } return; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 178 ms | 12852 KB | Reported list of edges differ from actual. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 178 ms | 12852 KB | Reported list of edges differ from actual. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 916 KB | Too many calls to get_distance(). |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 916 KB | Too many calls to get_distance(). |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 178 ms | 12852 KB | Reported list of edges differ from actual. |
2 | Halted | 0 ms | 0 KB | - |