QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#168617#6639. Disk Treeucup-team1209#TL 2022ms141312kbC++202.0kb2023-09-08 18:03:282023-09-08 18:03:28

Judging History

你现在查看的是最新测评结果

  • [2023-09-08 18:03:28]
  • 评测
  • 测评结果:TL
  • 用时:2022ms
  • 内存:141312kb
  • [2023-09-08 18:03:28]
  • 提交

answer

#include<bits/stdc++.h>
using std::cin;
using std::cout;
const int N = 200005;


using db = double;
using cp = std::complex<db>;
const db pi = std::acos(-1);

std::mt19937 gen(time(0) + (size_t) new char);
int n;
cp a[N], b[N];
int r[N], id0[N], id1[N];
int pos[N];
struct edge { int u, v; db w; };
std::vector<edge> e;
int anc[N];
db dist(int x, int y) { return abs(a[x] - a[y]) - r[x] - r[y]; }
struct pr {
	db w; int id;
} bit[N];
int find(int x) {
	return anc[x] == x ? x : anc[x] = find(anc[x]);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0);
	cin >> n;
	for(int i = 0;i < n;++i) {
		int x, y; cin >> x >> y >> r[i];
		a[i] = cp(x, y);
		id0[i] = i;
		id1[i] = i;
		anc[i] = i;
	}
	for(int i = 0;i < 50;++i) {
		cp r = std::polar(1., db(gen()) / gen.max() * pi * 4);
		for(int i = 0;i < n;++i) b[i] = a[i] * r;
		std::sort(id0, id0 + n, [](int x, int y) { return b[x].real() < b[y].real(); });
		std::sort(id1, id1 + n, [](int x, int y) { return b[x].imag() < b[y].imag(); });
		for(int j = 0;j < n;++j) {
			pos[id1[j]] = j + 1;
		}
		for(int i = 1;i <= n;++i) {
			bit[i] = {5e9, -1};
		}
		for(int i = n - 1;i >= 0;--i) {
			int x = id0[i];

			int id = -1;
			db dx = 5e9;

			for(int i = pos[x];i <= n;i += i & -i) {
				int t = bit[i].id;
				if(t != -1) {
					db dd = dist(t, x);
					if(id == -1) {
						id = t;
						dx = dd;
					} else {
						if(dd < dx) {
							dx = dd;
							id = t;
						}
					}
				}
			}

			pr z = { b[x].real() + b[x].imag() - ::r[x], x};
			for(int i = pos[x];i;i &= i - 1) {
				if(z.w < bit[i].w) bit[i] = z;
			}
			if(id >= 0) {
				e.push_back({x, id, dx});
			}
		}
	}
	sort(e.begin(), e.end(), [](edge x, edge y) { return x.w < y.w; });
	cout << "YES" << '\n';
	for(auto [u, v, w] : e) {
		if(find(u) != find(v)) {
			cout << (int) a[u].real() << ' ' << (int) a[u].imag() << ' ';
			cout << (int) a[v].real() << ' ' << (int) a[v].imag() << '\n';
			anc[find(u)] = find(v);
		}
	}
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3868kb

input:

3
1 0 3
10 10 6
0 5 1

output:

YES
1 0 0 5
0 5 10 10

result:

ok answer = 1

Test #2:

score: 0
Accepted
time: 1ms
memory: 3896kb

input:

2
1 1 1
3 3 1

output:

YES
3 3 1 1

result:

ok answer = 1

Test #3:

score: 0
Accepted
time: 1ms
memory: 3704kb

input:

5
10 10 10
2 0 1
20 20 1
3 20 1
20 0 1

output:

YES
3 20 10 10
10 10 2 0
20 20 10 10
10 10 20 0

result:

ok answer = 1

Test #4:

score: 0
Accepted
time: 1ms
memory: 3708kb

input:

10
29 29 2
28 55 10
99 81 4
17 82 10
45 88 10
48 68 10
0 8 10
98 95 10
34 0 10
17 24 10

output:

YES
98 95 99 81
45 88 48 68
29 29 17 24
0 8 17 24
28 55 48 68
45 88 17 82
34 0 17 24
17 24 28 55
45 88 98 95

result:

ok answer = 1

Test #5:

score: 0
Accepted
time: 2ms
memory: 3928kb

input:

100
490 783 12
666 460 55
561 245 6
223 323 25
3 520 77
225 161 24
514 190 16
997 914 100
412 265 100
374 610 36
296 854 39
601 901 2
307 21 100
390 422 24
940 414 32
332 438 35
553 992 100
235 775 3
656 901 37
770 417 22
649 305 100
448 84 3
375 939 77
910 847 9
776 357 37
743 97 100
371 502 39
508...

output:

YES
649 305 560 422
468 868 375 939
742 210 743 97
92 366 204 512
448 84 447 40
307 21 205 100
964 284 837 286
811 693 809 794
375 939 293 965
865 52 981 11
375 939 296 854
304 613 374 610
252 629 160 703
445 639 563 635
899 204 964 284
160 703 119 603
458 464 508 524
116 850 67 952
76 226 95 208
13...

result:

ok answer = 1

Test #6:

score: 0
Accepted
time: 3ms
memory: 4020kb

input:

200
2948 9798 687
3897 647 35
3918 587 28
1262 2717 206
1315 9524 20
2381 305 1000
4344 6858 20
6234 8949 53
5168 4772 85
5044 6109 158
72 7670 132
7300 1213 837
5427 2263 1000
1785 3009 276
6136 1421 43
1629 5620 29
6445 9489 242
8443 3141 1000
4118 4307 63
1874 5238 291
1964 5785 73
7794 3934 18
3...

output:

YES
4160 6939 3841 6121
1566 4450 1828 4099
5710 4771 5901 4668
7300 1213 6334 1443
4775 842 4278 321
4344 6858 4160 6939
4718 3379 4284 3385
9446 2407 9940 2103
8040 7929 7634 8387
8591 1690 8914 1613
2381 305 2395 2085
9671 1058 8844 424
8914 1613 8844 424
147 1148 63 2852
7502 5454 6908 4386
6908...

result:

ok answer = 1

Test #7:

score: 0
Accepted
time: 4ms
memory: 3956kb

input:

300
42942 37079 222
49441 21821 1695
61023 31153 561
86630 26307 352
36940 78253 213
7841 81086 626
47425 22290 374
17694 68695 648
38259 64794 998
43599 46942 9662
9204 2816 1965
38652 83568 4057
4046 29001 1034
72591 63214 587
75984 64859 1112
70005 72177 576
34522 52126 652
56627 48785 1747
78820...

output:

YES
59945 7276 59944 148
26217 53454 15549 49146
30743 15955 27055 9398
54156 44092 54720 46175
46373 81005 42729 76361
49555 87747 48642 86091
49759 86207 48642 86091
74594 17647 77261 898
90608 87653 83657 87664
9726 31739 710 39900
90608 87653 84773 93522
11003 92828 908 79893
62892 19999 74594 1...

result:

ok answer = 1

Test #8:

score: 0
Accepted
time: 12ms
memory: 4548kb

input:

1000
558504245 246224785 100000000
971981730 913036757 1821458
198791767 482624549 5998171
540520619 353988177 8924682
183178222 46223569 9859905
118485076 22129062 7497235
274928891 417171180 372954
230079763 468235825 289869
859092765 562864738 5551376
129036518 743777318 3969979
265158223 3092933...

output:

YES
935651301 194859808 969959032 159770753
407855873 545059764 387522770 540197621
758581132 629433365 792974301 599903526
803699647 926616709 709709305 895610707
951999910 625259461 957410466 524462618
805699634 244675073 842117276 266665723
9506894 429721563 21557591 472068545
606567077 439287468...

result:

ok answer = 1

Test #9:

score: 0
Accepted
time: 33ms
memory: 7820kb

input:

3000
442876143 334276354 3627270
526253918 947313397 2498956
566692880 229330019 4243066
497859604 658736917 13012787
315969653 65582717 1400013
394215653 932651144 1655676
58249045 973232518 860150
860773683 959388251 1594726
23803673 921365885 5926749
730359196 818999592 1521282
971839312 22835235...

output:

YES
281268489 57797275 290472947 49435962
338210244 314788266 336396685 305520991
511679958 472770476 504627632 484355357
381063725 888883942 385991211 898942427
106386194 648286633 109415638 638809020
443740179 557407886 445317829 548859629
278141533 211881820 287619836 198910855
34366085 912644950...

result:

ok answer = 1

Test #10:

score: 0
Accepted
time: 101ms
memory: 12228kb

input:

7000
601805179 978984160 464352
918208048 607538668 2214109
328147216 806677103 3901695
961794394 719893281 1114470
453816635 992288784 274949
778724702 692479905 1170018
169287513 886715521 576156
812072299 118324465 93778
726229729 150105801 3593039
368683874 642143790 1277375
40087476 151799345 4...

output:

YES
948962033 192473096 952741689 195407765
335978465 621454749 302136515 662205213
181702051 225543777 191910423 222317550
108639664 832228566 112166501 828136227
367657522 874112964 360578188 879715637
395639996 56994662 409421203 1671512
113675287 272880588 115667148 196841066
660724674 691603733...

result:

ok answer = 1

Test #11:

score: 0
Accepted
time: 133ms
memory: 12508kb

input:

10000
645 4710 5
1554 4072 7
6505 2760 1
6125 8212 11
9802 9537 3
6584 4356 6
1104 6649 23
4580 2623 20
3107 2460 1
4689 1662 2
7815 161 14
8718 3658 28
2900 63 15
1741 7296 44
8380 4608 50
2212 8514 4
7919 3069 17
1638 6057 3
504 9867 18
7869 8021 14
866 9239 5
3452 8042 4
9049 7222 4
4447 1004 5
9...

output:

YES
9942 7773 9941 6761
8379 5377 8980 5036
1140 9308 1806 9435
3934 629 3270 702
2042 8866 1806 9435
588 4254 54 4255
1698 6223 1697 6744
2832 3345 3511 4090
7950 3959 7500 3958
7500 3958 7062 3959
7501 4394 7500 3958
5924 7630 5549 7629
8576 4074 8575 4441
8362 3787 8576 4074
6477 9628 6424 9977
2...

result:

ok answer = 1

Test #12:

score: 0
Accepted
time: 2022ms
memory: 141312kb

input:

100000
956095525 596102106 2
461544095 587257542 118
884402350 357055086 14228
547768407 186052059 263162
827807425 303694996 474924
692537425 44608243 131609
504660936 451030143 15134
207539367 899608364 20283
919236289 724317925 6
386476373 727023405 323
781914406 792770865 1064
411548762 2476126 ...

output:

YES
892696561 422861520 892145544 423239295
737182558 31629185 737205369 31606130
790259785 35554795 791386989 34057684
575900390 197298321 576712653 196103190
871840112 672618377 871778107 671901046
972388111 699494151 971859066 699788760
606473337 946634089 607697634 947278085
267828294 606295817 ...

result:

ok answer = 1

Test #13:

score: -100
Time Limit Exceeded

input:

200000
267774456 105702394 770
297991198 776424841 124
703700092 120262616 341808
212663821 221756923 367
195031049 705083745 66
692227605 63745620 1221
615879799 481139131 3053
93198187 239262367 141042
645539116 89213985 1679
312339485 547897747 2701
546940040 418847605 2
100457345 231142218 2
290...

output:


result: