# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
674891 | 2022-12-26T13:11:02 Z | QwertyPi | City Mapping (NOI18_citymapping) | C++14 | 18 ms | 2668 KB |
#include "citymapping.h" #include <bits/stdc++.h> using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); struct edge{ int u, v, w; }; vector<edge> E; const int MAXN = 1e3 + 11; long long d[MAXN]; bool done[MAXN]; void solve(vector<int> v){ if(v.size() == 1) return; for(auto i : v) done[i] = false; int id = rng() % v.size(); int rt = v[id]; d[rt] = 0; done[rt] = true; for(auto i : v){ if(i != rt) d[i] = get_distance(rt, i); } while(true){ int ch = -1; for(auto i : v){ if(!done[i] && (ch == -1 || d[ch] > d[i])) ch = i; } if(ch == -1) break; done[ch] = true; E.push_back({rt, ch, d[ch]}); vector<long long> d2(MAXN); vector<int> sub_tree {ch}; for(auto i : v){ if(!done[i] && i != ch) { d2[i] = get_distance(ch, i); if(d2[i] <= d[i]) sub_tree.push_back(i), done[i] = true; } } solve(sub_tree); } } void find_roads(int N, int Q, int A[], int B[], int W[]) { vector<int> v; for(int i = 1; i <= N; i++){ v.push_back(i); } solve(v); for(int i = 0; i < E.size(); i++){ A[i] = E[i].u, B[i] = E[i].v, W[i] = E[i].w; } return; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 596 KB | Correct: 27580 out of 500000 queries used. |
2 | Correct | 5 ms | 852 KB | Correct: 44554 out of 500000 queries used. |
3 | Correct | 18 ms | 2668 KB | Correct: 238615 out of 500000 queries used. |
4 | Correct | 17 ms | 2620 KB | Correct: 256623 out of 500000 queries used. |
5 | Correct | 7 ms | 1152 KB | Correct: 77535 out of 500000 queries used. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 596 KB | Correct: 27580 out of 500000 queries used. |
2 | Correct | 5 ms | 852 KB | Correct: 44554 out of 500000 queries used. |
3 | Correct | 18 ms | 2668 KB | Correct: 238615 out of 500000 queries used. |
4 | Correct | 17 ms | 2620 KB | Correct: 256623 out of 500000 queries used. |
5 | Correct | 7 ms | 1152 KB | Correct: 77535 out of 500000 queries used. |
6 | Correct | 4 ms | 600 KB | Correct: 23039 out of 500000 queries used. |
7 | Correct | 4 ms | 724 KB | Correct: 33120 out of 500000 queries used. |
8 | Correct | 11 ms | 1568 KB | Correct: 122786 out of 500000 queries used. |
9 | Correct | 10 ms | 1400 KB | Correct: 93523 out of 500000 queries used. |
10 | Correct | 8 ms | 1236 KB | Correct: 71943 out of 500000 queries used. |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Too many calls to get_distance(). |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 2 ms | 596 KB | Too many calls to get_distance(). |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 596 KB | Correct: 27580 out of 500000 queries used. |
2 | Correct | 5 ms | 852 KB | Correct: 44554 out of 500000 queries used. |
3 | Correct | 18 ms | 2668 KB | Correct: 238615 out of 500000 queries used. |
4 | Correct | 17 ms | 2620 KB | Correct: 256623 out of 500000 queries used. |
5 | Correct | 7 ms | 1152 KB | Correct: 77535 out of 500000 queries used. |
6 | Correct | 4 ms | 600 KB | Correct: 23039 out of 500000 queries used. |
7 | Correct | 4 ms | 724 KB | Correct: 33120 out of 500000 queries used. |
8 | Correct | 11 ms | 1568 KB | Correct: 122786 out of 500000 queries used. |
9 | Correct | 10 ms | 1400 KB | Correct: 93523 out of 500000 queries used. |
10 | Correct | 8 ms | 1236 KB | Correct: 71943 out of 500000 queries used. |
11 | Incorrect | 2 ms | 596 KB | Too many calls to get_distance(). |
12 | Halted | 0 ms | 0 KB | - |