# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
963483 | 2024-04-15T06:57:15 Z | sleepntsheep | City Mapping (NOI18_citymapping) | C++17 | 1 ms | 628 KB |
#include "citymapping.h" #include <vector> #include <algorithm> #define N 1005 void find_roads(int n, int q, int A[], int B[], int W[]) { if (q != 12000) return; int root = 1, ad = -1; long long d[N] = { 0 }, e[N] = { 0 }; for (int i = 2; i <= n; ++i) { d[i] = get_distance(root, i); if (ad == -1 || d[i] < d[ad]) ad = i; } for (int i = 1; i <= n; ++i) e[i] = get_distance(ad, i); std::vector<int> left, right; left.push_back(ad); for (int i = 1; i <= n; ++i) { if (i == ad || i == root) continue; if (e[i] < d[i]) left.push_back(i); else right.push_back(i); } std::sort(left.begin(), left.end(), [&](int i, int j){ return d[i] < d[j] ; }); std::sort(right.begin(), right.end(), [&](int i, int j){ return d[i] < d[j] ; }); for (int pre = root, i = 0; i < left.size(); ++i) { A[i] = pre; B[i] = left[i]; W[i] = d[left[i]] - d[pre]; pre = B[i]; } for (int pre = root, j = 0, i = left.size(); i < n - 1; ++i, ++j) { A[i] = pre; B[i] = right[j]; W[i] = d[right[j]] - d[pre]; pre = B[i]; } return; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | Reported list of edges differ from actual. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | Reported list of edges differ from actual. |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Correct: 1981 out of 12000 queries used. |
2 | Correct | 1 ms | 604 KB | Correct: 1985 out of 12000 queries used. |
3 | Correct | 1 ms | 604 KB | Correct: 1999 out of 12000 queries used. |
4 | Correct | 1 ms | 604 KB | Correct: 1985 out of 12000 queries used. |
5 | Correct | 1 ms | 600 KB | Correct: 1981 out of 12000 queries used. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 604 KB | Correct: 1981 out of 12000 queries used. |
2 | Correct | 1 ms | 604 KB | Correct: 1985 out of 12000 queries used. |
3 | Correct | 1 ms | 604 KB | Correct: 1999 out of 12000 queries used. |
4 | Correct | 1 ms | 604 KB | Correct: 1985 out of 12000 queries used. |
5 | Correct | 1 ms | 600 KB | Correct: 1981 out of 12000 queries used. |
6 | Correct | 1 ms | 604 KB | Correct: 1995 out of 12000 queries used. |
7 | Correct | 1 ms | 604 KB | Correct: 1991 out of 12000 queries used. |
8 | Correct | 1 ms | 628 KB | Correct: 1999 out of 12000 queries used. |
9 | Correct | 1 ms | 604 KB | Correct: 1993 out of 12000 queries used. |
10 | Correct | 1 ms | 604 KB | Correct: 1987 out of 12000 queries used. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 600 KB | Reported list of edges differ from actual. |
2 | Halted | 0 ms | 0 KB | - |