답안 #1030976

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1030976 2024-07-22T13:11:20 Z vjudge1 City Mapping (NOI18_citymapping) C++17
25 / 100
36 ms 668 KB
#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;
	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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 600 KB Correct: 253181 out of 500000 queries used.
2 Correct 17 ms 604 KB Correct: 259564 out of 500000 queries used.
3 Correct 11 ms 480 KB Correct: 246764 out of 500000 queries used.
4 Correct 11 ms 600 KB Correct: 269573 out of 500000 queries used.
5 Correct 17 ms 660 KB Correct: 254332 out of 500000 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 600 KB Correct: 253181 out of 500000 queries used.
2 Correct 17 ms 604 KB Correct: 259564 out of 500000 queries used.
3 Correct 11 ms 480 KB Correct: 246764 out of 500000 queries used.
4 Correct 11 ms 600 KB Correct: 269573 out of 500000 queries used.
5 Correct 17 ms 660 KB Correct: 254332 out of 500000 queries used.
6 Correct 30 ms 600 KB Correct: 495510 out of 500000 queries used.
7 Correct 34 ms 604 KB Correct: 497495 out of 500000 queries used.
8 Correct 28 ms 604 KB Correct: 497503 out of 500000 queries used.
9 Correct 27 ms 604 KB Correct: 495510 out of 500000 queries used.
10 Correct 36 ms 668 KB Correct: 496506 out of 500000 queries used.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Too many calls to get_distance().
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 600 KB Too many calls to get_distance().
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 600 KB Correct: 253181 out of 500000 queries used.
2 Correct 17 ms 604 KB Correct: 259564 out of 500000 queries used.
3 Correct 11 ms 480 KB Correct: 246764 out of 500000 queries used.
4 Correct 11 ms 600 KB Correct: 269573 out of 500000 queries used.
5 Correct 17 ms 660 KB Correct: 254332 out of 500000 queries used.
6 Correct 30 ms 600 KB Correct: 495510 out of 500000 queries used.
7 Correct 34 ms 604 KB Correct: 497495 out of 500000 queries used.
8 Correct 28 ms 604 KB Correct: 497503 out of 500000 queries used.
9 Correct 27 ms 604 KB Correct: 495510 out of 500000 queries used.
10 Correct 36 ms 668 KB Correct: 496506 out of 500000 queries used.
11 Incorrect 1 ms 600 KB Too many calls to get_distance().
12 Halted 0 ms 0 KB -