Submission #1030989

#TimeUsernameProblemLanguageResultExecution timeMemory
1030989vjudge1City Mapping (NOI18_citymapping)C++17
32 / 100
1 ms604 KiB
#include "citymapping.h" #include <bits/stdc++.h> using namespace std; #define int long long const int N = 1e3+3; mt19937 rng(time(nullptr) + 69); int n, nd[N], deg[N]; pair<int, int> p[N], d[N]; void find_roads(signed N, signed Q, signed A[], signed B[], signed W[]) { n = N; d[0] = make_pair(0, 1); for (int i = 2; i <= n; i++) { d[i-1] = make_pair(get_distance(1, i), i); } sort(d, d+n); int x = d[n-1].second; for (int i = 1; i <= n; i++) { if (x == i) d[i-1] = make_pair(0, x); else d[i-1] = make_pair(get_distance(x, i), i); } sort(d, d+n); for (int i = 0; i < n-1; i++) { A[i] = d[i].second; B[i] = d[i+1].second; W[i] = d[i+1].first - d[i].first; } /* for (int i = 0; i < n; i++) { nd[i] = i+1; deg[i] = 0; } shuffle(nd, nd+n, rng); d[0] = make_pair(0, nd[0]); for (int i = 1; i < n; i++) { d[i] = make_pair(get_distance(nd[0], nd[i]), nd[i]); } sort(d, d+n); set<int> st; for (int i = 1; i < n; i++) { int mn = d[i].first; int best = nd[0]; for (int j : st) { if (mn == 1) break; int x = get_distance(j, d[i].second); if (x < mn) { mn = x; best = j; } } p[d[i].second] = make_pair(best, mn); if (++deg[best] == 3) { st.erase(best); } st.insert(d[i].second); } for (int i = 0; i < N-1; i++) { A[i] = p[nd[i+1]].first; B[i] = nd[i+1]; W[i] = p[nd[i+1]].second; } return; */ }
#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...