답안 #964767

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
964767 2024-04-17T14:02:41 Z guechotjrhh City Mapping (NOI18_citymapping) C++14
92.28 / 100
2 ms 760 KB
#include "citymapping.h"
#include<vector>
#include<algorithm>
#include<random>
#include<iostream>
using namespace std;
#define ll long long
#define pi pair<ll,ll>
#define x first
#define y second

random_device rd;
mt19937 g(rd());
random_device r;
default_random_engine e1(r());
uniform_int_distribution<int> ud(0, 1e9 + 7);
int * a, * b, * w, p = 0;
void func(vector<pi> &v) {//sorted?
	int n = v.size();
	if (n == 1) return;
	int piv = ud(e1) % v.size();
	while(piv == 0) piv = ud(e1)%v.size();
	vector<int> lv;
	vector<vector<pi>> nv;
	lv.push_back(0);
	lv.push_back(piv);
	nv.push_back({});
	nv.push_back({});
	int s = 1;
	for (int i = 1; i < n; i++) {
		if (i == piv) continue;
		ll w = get_distance(v[i].x, v[lv[s]].x);
		ll t = (v[i].y + v[lv[s]].y - w) / 2;
		
		if (w == v[lv[s]].y - v[i].y) {
			lv[s] = i;
			lv.push_back(piv);
			nv.push_back({});
			s++;
		}
		else {
			int j = 0;
			while (t > v[lv[j]].y) j++;
			if (j == s) {
				nv.push_back({});
				lv.push_back(i);
				s++;
			}
			else {
				nv[j].push_back(v[i]);
			}
		}
	}
	for (int i = 1; i <= s; i++) {
		a[p] = v[lv[i]].x; b[p] = v[lv[i - 1]].x; w[p] = v[lv[i]].y - v[lv[i - 1]].y; p++;
	}
	for (int i = 0; i <= s; i++) {
		if (nv[i].size()) {
			a[p] = v[lv[i]].x; b[p] = nv[i][0].x; w[p] = nv[i][0].y - v[lv[i]].y; p++;
			ll o = nv[i][0].y;
			for (int j = 0; j < nv[i].size(); j++) nv[i][j].y -= o;
			func(nv[i]);
		}
	}
}

void find_roads(int N, int Q, int A[], int B[], int W[]) {
	a = A; b = B; w = W;
	int st = ud(e1) % N + 1;
	ll mx = 0, mi = st;
	for (int i = 1; i <= N; i++){
		if (i == st) continue;
		ll z = get_distance(st, i);
		if (z > mx) {
			mx = z;
			mi = i;
		}
	}
	vector<pi> vu = { { 0,mi } };
	for (int i = 1; i <= N; i++) if (i != mi) vu.push_back({ get_distance(mi,i), i });
	sort(vu.begin(), vu.end());
	vector<pi> vc(N);
	for (int i = 0; i < N; i++) vc[i] = { vu[i].y,vu[i].x };
	func(vc);
	return;
}

Compilation message

citymapping.cpp: In function 'void func(std::vector<std::pair<long long int, long long int> >&)':
citymapping.cpp:61:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   61 |    for (int j = 0; j < nv[i].size(); j++) nv[i][j].y -= o;
      |                    ~~^~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Correct: 2993 out of 500000 queries used.
2 Correct 1 ms 600 KB Correct: 4176 out of 500000 queries used.
3 Correct 2 ms 760 KB Correct: 5353 out of 500000 queries used.
4 Correct 1 ms 604 KB Correct: 6360 out of 500000 queries used.
5 Correct 1 ms 604 KB Correct: 4480 out of 500000 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Correct: 2993 out of 500000 queries used.
2 Correct 1 ms 600 KB Correct: 4176 out of 500000 queries used.
3 Correct 2 ms 760 KB Correct: 5353 out of 500000 queries used.
4 Correct 1 ms 604 KB Correct: 6360 out of 500000 queries used.
5 Correct 1 ms 604 KB Correct: 4480 out of 500000 queries used.
6 Correct 2 ms 604 KB Correct: 2984 out of 500000 queries used.
7 Correct 2 ms 604 KB Correct: 2990 out of 500000 queries used.
8 Correct 2 ms 604 KB Correct: 5367 out of 500000 queries used.
9 Correct 1 ms 604 KB Correct: 5731 out of 500000 queries used.
10 Correct 1 ms 604 KB Correct: 4784 out of 500000 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Correct: 2969 out of 12000 queries used.
2 Correct 1 ms 604 KB Correct: 2975 out of 12000 queries used.
3 Correct 1 ms 604 KB Correct: 2996 out of 12000 queries used.
4 Correct 1 ms 604 KB Correct: 2975 out of 12000 queries used.
5 Correct 1 ms 600 KB Correct: 2969 out of 12000 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Correct: 2969 out of 12000 queries used.
2 Correct 1 ms 604 KB Correct: 2975 out of 12000 queries used.
3 Correct 1 ms 604 KB Correct: 2996 out of 12000 queries used.
4 Correct 1 ms 604 KB Correct: 2975 out of 12000 queries used.
5 Correct 1 ms 600 KB Correct: 2969 out of 12000 queries used.
6 Correct 2 ms 604 KB Correct: 2990 out of 12000 queries used.
7 Correct 1 ms 604 KB Correct: 2984 out of 12000 queries used.
8 Correct 2 ms 600 KB Correct: 2996 out of 12000 queries used.
9 Correct 2 ms 600 KB Correct: 2987 out of 12000 queries used.
10 Correct 1 ms 600 KB Correct: 2978 out of 12000 queries used.
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 600 KB Correct: 2993 out of 500000 queries used.
2 Correct 1 ms 600 KB Correct: 4176 out of 500000 queries used.
3 Correct 2 ms 760 KB Correct: 5353 out of 500000 queries used.
4 Correct 1 ms 604 KB Correct: 6360 out of 500000 queries used.
5 Correct 1 ms 604 KB Correct: 4480 out of 500000 queries used.
6 Correct 2 ms 604 KB Correct: 2984 out of 500000 queries used.
7 Correct 2 ms 604 KB Correct: 2990 out of 500000 queries used.
8 Correct 2 ms 604 KB Correct: 5367 out of 500000 queries used.
9 Correct 1 ms 604 KB Correct: 5731 out of 500000 queries used.
10 Correct 1 ms 604 KB Correct: 4784 out of 500000 queries used.
11 Correct 1 ms 604 KB Correct: 2969 out of 12000 queries used.
12 Correct 1 ms 604 KB Correct: 2975 out of 12000 queries used.
13 Correct 1 ms 604 KB Correct: 2996 out of 12000 queries used.
14 Correct 1 ms 604 KB Correct: 2975 out of 12000 queries used.
15 Correct 1 ms 600 KB Correct: 2969 out of 12000 queries used.
16 Correct 2 ms 604 KB Correct: 2990 out of 12000 queries used.
17 Correct 1 ms 604 KB Correct: 2984 out of 12000 queries used.
18 Correct 2 ms 600 KB Correct: 2996 out of 12000 queries used.
19 Correct 2 ms 600 KB Correct: 2987 out of 12000 queries used.
20 Correct 1 ms 600 KB Correct: 2978 out of 12000 queries used.
21 Correct 1 ms 600 KB Correct: 2984 out of 25000 queries used.
22 Correct 1 ms 604 KB Correct: 3919 out of 25000 queries used.
23 Correct 1 ms 604 KB Correct: 3455 out of 25000 queries used.
24 Correct 2 ms 600 KB Correct: 2972 out of 25000 queries used.
25 Correct 1 ms 484 KB Correct: 5543 out of 25000 queries used.
26 Correct 2 ms 604 KB Correct: 5690 out of 25000 queries used.
27 Correct 2 ms 604 KB Correct: 5586 out of 25000 queries used.
28 Correct 2 ms 488 KB Correct: 6463 out of 25000 queries used.
29 Correct 1 ms 488 KB Correct: 5523 out of 25000 queries used.
30 Correct 2 ms 532 KB Correct: 6013 out of 25000 queries used.
31 Correct 1 ms 604 KB Correct: 6666 out of 25000 queries used.
32 Correct 1 ms 604 KB Correct: 2981 out of 25000 queries used.
33 Correct 1 ms 604 KB Correct: 6586 out of 25000 queries used.
34 Correct 1 ms 604 KB Correct: 5745 out of 25000 queries used.
35 Correct 1 ms 604 KB Correct: 5759 out of 25000 queries used.
36 Correct 1 ms 740 KB Correct: 6316 out of 25000 queries used.
37 Correct 1 ms 604 KB Correct: 5716 out of 25000 queries used.
38 Correct 1 ms 600 KB Correct: 5721 out of 25000 queries used.
39 Correct 1 ms 500 KB Correct: 5713 out of 25000 queries used.
40 Correct 2 ms 604 KB Correct: 5696 out of 25000 queries used.
41 Correct 1 ms 600 KB Correct: 5765 out of 25000 queries used.
42 Correct 1 ms 604 KB Correct: 6375 out of 25000 queries used.
43 Correct 1 ms 600 KB Correct: 2990 out of 25000 queries used.
44 Correct 1 ms 612 KB Correct: 6277 out of 25000 queries used.
45 Correct 1 ms 604 KB Correct: 6535 out of 25000 queries used.
46 Correct 2 ms 604 KB Correct: 5635 out of 25000 queries used.
47 Correct 2 ms 604 KB Correct: 5722 out of 25000 queries used.
48 Correct 2 ms 668 KB Correct: 5723 out of 25000 queries used.
49 Correct 2 ms 488 KB Correct: 5693 out of 25000 queries used.
50 Correct 2 ms 604 KB Correct: 5979 out of 25000 queries used.
51 Correct 1 ms 604 KB Correct: 6633 out of 25000 queries used.
52 Correct 1 ms 604 KB Correct: 6738 out of 25000 queries used.
53 Correct 2 ms 484 KB Correct: 5720 out of 25000 queries used.
54 Correct 1 ms 604 KB Correct: 2996 out of 25000 queries used.
55 Correct 2 ms 604 KB Correct: 5970 out of 25000 queries used.
56 Correct 2 ms 548 KB Correct: 7365 out of 25000 queries used.
57 Correct 2 ms 600 KB Correct: 5739 out of 25000 queries used.
58 Correct 2 ms 608 KB Correct: 5674 out of 25000 queries used.
59 Correct 1 ms 604 KB Correct: 5642 out of 25000 queries used.
60 Correct 1 ms 608 KB Correct: 5239 out of 25000 queries used.
61 Correct 1 ms 488 KB Correct: 4473 out of 25000 queries used.
62 Correct 1 ms 528 KB Correct: 3969 out of 25000 queries used.
63 Correct 1 ms 600 KB Correct: 3970 out of 25000 queries used.
64 Correct 1 ms 540 KB Correct: 5094 out of 25000 queries used.
65 Correct 2 ms 604 KB Correct: 2969 out of 25000 queries used.
66 Correct 2 ms 612 KB Correct: 3884 out of 25000 queries used.
67 Correct 1 ms 628 KB Correct: 3745 out of 25000 queries used.
68 Correct 2 ms 600 KB Correct: 3681 out of 25000 queries used.
69 Correct 1 ms 604 KB Correct: 2987 out of 25000 queries used.
70 Correct 2 ms 488 KB Correct: 2978 out of 25000 queries used.