Submission #93513

#TimeUsernameProblemLanguageResultExecution timeMemory
93513adminCity Mapping (NOI18_citymapping)C++17
0 / 100
37 ms504 KiB
#include "citymapping.h" #include <bits/stdc++.h> using namespace std; using lint = long long; using pil = pair<int, long long>; void find_roads(int N, int Q, int A[], int B[], int W[]) { const int ROOT = 1; vector<pil> internal; for(int u = 1; u <= N; u++) { internal.emplace_back(u, (u == ROOT) ? 0 : get_distance(ROOT, u)); } sort(internal.begin(), internal.end(), [&](const pil &p, const pil &q) { return p.second < q.second; }); int e = 0; for(unsigned i = 1; i < internal.size(); i++) { int u = internal[i].first; int v = -1; lint d = 1e18; for(unsigned j = 0; j < i; j++) { int p = internal[j].first; lint c = get_distance(u, p); if(v == -1 || d > c) { d = c; v = p; } } A[e] = u; B[e] = v; W[e] = d; e += 1; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...