답안 #836243

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
836243 2023-08-24T09:04:35 Z unnick City Mapping (NOI18_citymapping) C++14
41 / 100
43 ms 592 KB
#include "citymapping.h"

// #include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

#define ll long long

void find_roads(int N, int Q, int A[], int B[], int W[]) {
	if (Q <= 12000) {
		int start;
		{
			ll maxd = 0;
			for (int i = 2; i <= N; i++) {
				ll d = get_distance(1, i);
				if (d > maxd) {
					maxd = d;
					start = i;
				}
			}
		}
		vector<ll> dists(N);
		dists[start-1] = 0;
		vector<int> ids(N);
		iota(ids.begin(), ids.end(), 0);
		for (int i = 1; i <= N; i++) {
			if (i == start) continue;
			dists[i-1] = get_distance(start,i);
		}
		sort(ids.begin(), ids.end(), [&](int a, int b) {
			return dists[a] < dists[b];
		});
		for (int i = 0; i < N-1; i++) {
			A[i] = ids[i]+1;
			B[i] = ids[i+1]+1;
			W[i] = dists[ids[i+1]] - dists[ids[i]];
		}
	} else {
		// vector<ll> dists(N*N);
		int k = 0;
		for (int i = 1; i <= N; i++) {
			for (int j = i+1; j <= N; j++) {
				if (get_distance(i,j) == 1) {
					A[k] = i;
					B[k] = j;
					W[k++] = 1;
				}
			}
		}
	}
}

Compilation message

citymapping.cpp: In function 'void find_roads(int, int, int*, int*, int*)':
citymapping.cpp:31:29: warning: 'start' may be used uninitialized in this function [-Wmaybe-uninitialized]
   31 |    dists[i-1] = get_distance(start,i);
      |                 ~~~~~~~~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 432 KB Correct: 498501 out of 500000 queries used.
2 Correct 33 ms 452 KB Correct: 499500 out of 500000 queries used.
3 Correct 26 ms 448 KB Correct: 492528 out of 500000 queries used.
4 Correct 22 ms 468 KB Correct: 494515 out of 500000 queries used.
5 Correct 35 ms 340 KB Correct: 498501 out of 500000 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 432 KB Correct: 498501 out of 500000 queries used.
2 Correct 33 ms 452 KB Correct: 499500 out of 500000 queries used.
3 Correct 26 ms 448 KB Correct: 492528 out of 500000 queries used.
4 Correct 22 ms 468 KB Correct: 494515 out of 500000 queries used.
5 Correct 35 ms 340 KB Correct: 498501 out of 500000 queries used.
6 Incorrect 27 ms 504 KB Reported list of edges differ from actual.
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Correct: 1980 out of 12000 queries used.
2 Correct 1 ms 468 KB Correct: 1984 out of 12000 queries used.
3 Correct 1 ms 468 KB Correct: 1998 out of 12000 queries used.
4 Correct 1 ms 468 KB Correct: 1984 out of 12000 queries used.
5 Correct 1 ms 468 KB Correct: 1980 out of 12000 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 468 KB Correct: 1980 out of 12000 queries used.
2 Correct 1 ms 468 KB Correct: 1984 out of 12000 queries used.
3 Correct 1 ms 468 KB Correct: 1998 out of 12000 queries used.
4 Correct 1 ms 468 KB Correct: 1984 out of 12000 queries used.
5 Correct 1 ms 468 KB Correct: 1980 out of 12000 queries used.
6 Correct 1 ms 468 KB Correct: 1994 out of 12000 queries used.
7 Correct 2 ms 592 KB Correct: 1990 out of 12000 queries used.
8 Correct 1 ms 468 KB Correct: 1998 out of 12000 queries used.
9 Correct 1 ms 468 KB Correct: 1992 out of 12000 queries used.
10 Correct 1 ms 468 KB Correct: 1986 out of 12000 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 432 KB Correct: 498501 out of 500000 queries used.
2 Correct 33 ms 452 KB Correct: 499500 out of 500000 queries used.
3 Correct 26 ms 448 KB Correct: 492528 out of 500000 queries used.
4 Correct 22 ms 468 KB Correct: 494515 out of 500000 queries used.
5 Correct 35 ms 340 KB Correct: 498501 out of 500000 queries used.
6 Incorrect 27 ms 504 KB Reported list of edges differ from actual.
7 Halted 0 ms 0 KB -