QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#168620#6639. Disk Treeucup-team1209#TL 1633ms79960kbC++202.0kb2023-09-08 18:05:592023-09-08 18:06:00

Judging History

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

  • [2023-09-08 18:06:00]
  • 评测
  • 测评结果:TL
  • 用时:1633ms
  • 内存:79960kb
  • [2023-09-08 18:05:59]
  • 提交

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 < 40;++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: 2ms
memory: 9864kb

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: 3ms
memory: 12008kb

input:

2
1 1 1
3 3 1

output:

YES
1 1 3 3

result:

ok answer = 1

Test #3:

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

input:

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

output:

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

result:

ok answer = 1

Test #4:

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

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
99 81 98 95
48 68 45 88
17 24 29 29
0 8 17 24
28 55 48 68
17 82 45 88
34 0 17 24
17 24 28 55
98 95 45 88

result:

ok answer = 1

Test #5:

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

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

result:

ok answer = 1

Test #6:

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

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
5901 4668 5710 4771
7300 1213 6334 1443
4278 321 4775 842
4344 6858 4160 6939
4284 3385 4718 3379
9940 2103 9446 2407
8040 7929 7634 8387
8914 1613 8591 1690
2395 2085 2381 305
9671 1058 8844 424
8844 424 8914 1613
147 1148 63 2852
7502 5454 6908 4386
6837...

result:

ok answer = 1

Test #7:

score: 0
Accepted
time: 0ms
memory: 12140kb

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

result:

ok answer = 1

Test #8:

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

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
387522770 540197621 407855873 545059764
758581132 629433365 792974301 599903526
803699647 926616709 709709305 895610707
951999910 625259461 957410466 524462618
842117276 266665723 805699634 244675073
21557591 472068545 9506894 429721563
606567077 439287468...

result:

ok answer = 1

Test #9:

score: 0
Accepted
time: 29ms
memory: 13820kb

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
336396685 305520991 338210244 314788266
504627632 484355357 511679958 472770476
385991211 898942427 381063725 888883942
109415638 638809020 106386194 648286633
445317829 548859629 443740179 557407886
278141533 211881820 287619836 198910855
34366085 912644950...

result:

ok answer = 1

Test #10:

score: 0
Accepted
time: 79ms
memory: 20064kb

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
952741689 195407765 948962033 192473096
302136515 662205213 335978465 621454749
181702051 225543777 191910423 222317550
108639664 832228566 112166501 828136227
360578188 879715637 367657522 874112964
409421203 1671512 395639996 56994662
115667148 196841066 113675287 272880588
660724674 691603733...

result:

ok answer = 1

Test #11:

score: 0
Accepted
time: 115ms
memory: 20200kb

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
1806 9435 1140 9308
3934 629 3270 702
1806 9435 2042 8866
588 4254 54 4255
1698 6223 1697 6744
2832 3345 3511 4090
7950 3959 7500 3958
7500 3958 7062 3959
7500 3958 7501 4394
5924 7630 5549 7629
8576 4074 8575 4441
8362 3787 8576 4074
6477 9628 6424 9977
4...

result:

ok answer = 1

Test #12:

score: 0
Accepted
time: 1633ms
memory: 79960kb

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
576712653 196103190 575900390 197298321
871778107 671901046 871840112 672618377
972388111 699494151 971859066 699788760
606473337 946634089 607697634 947278085
268325283 605404505 ...

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: