Submission #550002

# Submission time Handle Problem Language Result Execution time Memory
550002 2022-04-17T04:03:04 Z AKiko City Mapping (NOI18_citymapping) C++14
0 / 100
120 ms 8808 KB
#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());
	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[]) {
	if(Q > 25e3) {
		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

citymapping.cpp: In function 'std::vector<std::pair<long long int, std::pair<int, int> > > mst(int)':
citymapping.cpp:28:6: warning: unused variable 'c' [-Wunused-variable]
   28 |   ll c = el.ff;
      |      ^
citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:41:20: 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 time Memory Grader output
1 Incorrect 120 ms 8808 KB Reported list of edges differ from actual.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 8808 KB Reported list of edges differ from actual.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 472 KB Reported list of edges differ from actual.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 472 KB Reported list of edges differ from actual.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 8808 KB Reported list of edges differ from actual.
2 Halted 0 ms 0 KB -