Submission #550005

#TimeUsernameProblemLanguageResultExecution timeMemory
550005AKikoCity Mapping (NOI18_citymapping)C++14
25 / 100
116 ms8900 KiB
#include "citymapping.h" #include <bits/stdc++.h> #define pii pair<int, int> #define ll long long #define pb push_back #define ss second #define ff first using namespace std; vector<int> p(1e3 + 1); int find(int x) { if(x == p[x]) return x; return p[x] = find(p[x]); } vector<pair<ll, pii> > mst(int N) { vector<pair<ll, pii> > path, res; for(int i = 1; i <= N; i++) { for(int j = i + 1; j <= N; j++) { ll ans = get_distance(i, j); path.pb({ans, {i, j}}); } } sort(path.begin(), path.end()); iota(p.begin(), p.end(), 0); for(auto el : path) { int a = el.ss.ff, b = el.ss.ss; ll c = el.ff; int ap = find(a), bp = find(b); if(ap == bp) continue; p[bp] = ap; res.pb(el); } return res; } void find_roads(int N, int Q, int A[], int B[], int W[]) { vector<pair<ll, pii> > paths = mst(N); for(int i = 0; i < paths.size(); i++) { A[i] = paths[i].ss.ff; B[i] = paths[i].ss.ss; W[i] = paths[i].ff; } return; }

Compilation message (stderr)

citymapping.cpp: In function 'std::vector<std::pair<long long int, std::pair<int, int> > > mst(int)':
citymapping.cpp:29:6: warning: unused variable 'c' [-Wunused-variable]
   29 |   ll c = el.ff;
      |      ^
citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:41:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  for(int i = 0; i < paths.size(); i++) {
      |                 ~~^~~~~~~~~~~~~~
#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...