Submission #93514

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
935142019-01-09 07:34:45adminCity Mapping (NOI18_citymapping)C++17
25 / 100
39 ms508 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<lint> dist_to_root(N+1);
for(int u = 1; u <= N; u++) {
if(u != ROOT) dist_to_root[u] = get_distance(ROOT, u);
}
vector<int> internal(N);
iota(internal.begin(), internal.end(), 1);
sort(internal.begin(), internal.end(), [&](const int &p, const int &q) {
return dist_to_root[p] < dist_to_root[q];
});
int e = 0;
for(unsigned i = 1; i < internal.size(); i++) {
int u = internal[i];
int v = -1; lint d = 1e18;
for(unsigned j = 0; j < i; j++) {
int p = internal[j];
lint c = (j == 0) ? dist_to_root[u] : get_distance(u, p);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#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...