QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137581#2350. Integer CowBoulevardDust#TL 1933ms3880kbC++201.6kb2023-08-10 14:00:282023-08-10 14:07:13

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 14:07:13]
  • 评测
  • 测评结果:TL
  • 用时:1933ms
  • 内存:3880kb
  • [2023-08-10 14:00:28]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define y0 yyy0
typedef long long ll;
#define sz(x) (int)(x.size())
#define out(x) cerr << #x << " = " << x << " "
#define outln(x) cerr << #x << " = " << x << endl

const ll inf = 10000000000ll;
ll xc, yc, r, x0, y0;
ll s2(ll x) {return x * x;}

int main() {
	int t; scanf("%d", &t); while (t--) {
		scanf("%lld%lld%lld%lld%lld", &xc, &yc, &r, &x0, &y0);
		x0 -= xc, y0 -= yc;
		if (x0 * x0 + y0 * y0 <= r * r) {
			printf("0\n%lld %lld\n", x0 + xc, y0 + yc);
			continue;
		}
		ll ansx = 0ll, ansy = 0ll, dis = s2(x0) + s2(y0);
		if (x0 == 0) {
			if (y0 >= 0) ansx = x0, ansy = r;
			else ansx = x0, ansy = -r;
		} else if (y0 == 0) {
			if (x0 >= 0) ansx = r, ansy = y0;
			else ansx = -r, ansy = y0;
		} else {
			double D = sqrt(x0 * x0 + y0 * y0);
			double xx0 = r / D * x0, yy0 = r / D * y0;
			ll px = (ll)xx0, py = (ll)yy0;
			const int K = 2866;
			for (int i = -K; i <= K; ++i) {
				for (int j = -K; j <= K; ++j) {
					ll qx = px + i, qy = py + j;
					if (qx * qx + qy * qy <= r * r) {
						ll len = s2(qx - x0) + s2(qy - y0);
						if (len < dis) {
							dis = len;
							ansx = qx, ansy = qy;
						}
					}
				}
			}
			const int L = 1300;
			for (int i = -L; i <= L; ++i) {
				for (int j = -L; j <= L; ++j) {
					ll qx = i, qy = j;
					if (qx * qx + qy * qy <= r * r) {
						ll len = s2(qx - x0) + s2(qy - y0);
						if (len < dis) {
							dis = len;
							ansx = qx, ansy = qy;
						}
					}
				}
			}
		}
		x0 += xc, y0 += yc;
		ansx += xc, ansy += yc;
		printf("1\n%lld %lld %lld %lld\n", x0, y0, ansx, ansy); 
	}
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 21ms
memory: 3708kb

input:

3
1 2 1 1 2
3 2 5 -10 3
0 0 1 10 0

output:

0
1 2
1
-10 3 -2 2
1
10 0 1 0

result:

ok correct (3 test cases)

Test #2:

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

input:

1
0 0 1 0 0

output:

0
0 0

result:

ok correct (1 test case)

Test #3:

score: 0
Accepted
time: 1182ms
memory: 3640kb

input:

100
-1 0 2 -3 -2
0 -2 2 -2 0
2 -1 1 0 1
-1 -3 1 -1 0
-1 2 2 -1 -1
2 -2 2 0 -3
-2 -3 2 -3 -2
0 1 2 2 1
-1 0 1 -2 -2
2 -2 2 -1 -2
1 2 2 -2 2
-1 2 1 -1 2
-2 1 2 -3 -2
-1 1 1 -1 1
2 2 1 1 -3
2 0 1 -2 -1
-1 2 1 -2 0
2 -2 2 -2 -1
-2 -2 1 1 -2
-1 1 2 2 1
2 -3 1 0 -1
-3 -3 2 2 -1
2 1 1 -1 1
-3 -2 1 -2 -3
0 ...

output:

1
-3 -2 -2 -1
1
-2 0 -1 -1
1
0 1 1 -1
1
-1 0 -1 -2
1
-1 -1 -1 0
1
0 -3 0 -2
0
-3 -2
0
2 1
1
-2 -2 -1 -1
1
-1 -2 0 -2
1
-2 2 -1 2
0
-1 2
1
-3 -2 -2 -1
0
-1 1
1
1 -3 2 1
1
-2 -1 1 0
1
-2 0 -1 1
1
-2 -1 0 -2
1
1 -2 -1 -2
1
2 1 1 1
1
0 -1 1 -3
1
2 -1 -1 -3
1
-1 1 1 1
1
-2 -3 -3 -3
0
-2 -2
0
-2 -2
0
1 -1...

result:

ok correct (100 test cases)

Test #4:

score: 0
Accepted
time: 1662ms
memory: 3876kb

input:

100
-5 9 1 -2 -7
3 1 6 9 2
-2 -1 2 -7 3
-10 -8 7 -8 6
0 3 9 -6 -7
6 4 9 -1 4
8 6 7 -7 7
3 -7 7 2 0
-5 -1 6 -7 -7
-5 8 7 -9 -6
-6 -5 5 -10 -9
-7 1 9 7 -2
-4 9 4 8 3
3 -9 6 2 -2
-1 -7 3 -8 2
-2 -5 4 -1 0
1 2 9 -5 5
0 9 5 -4 -1
-10 8 2 -3 -7
-8 -3 3 2 -3
3 3 7 -4 6
6 0 6 -3 5
-7 5 9 9 9
2 0 2 8 -10
2 1...

output:

1
-2 -7 -5 8
1
9 2 8 2
1
-7 3 -4 -1
1
-8 6 -10 -1
1
-6 -7 -4 -5
0
-1 4
1
-7 7 1 6
1
2 0 2 -1
1
-7 -7 -7 -6
1
-9 -6 -8 2
1
-10 -9 -10 -8
1
7 -2 2 1
1
8 3 -1 7
1
2 -2 3 -3
1
-8 2 -3 -5
1
-1 0 -2 -1
0
-5 5
1
-4 -1 -3 5
1
-3 -7 -10 6
1
2 -3 -5 -3
1
-4 6 -3 6
1
-3 5 1 3
1
9 9 1 9
1
8 -10 2 -2
1
7 -1 5 1
...

result:

ok correct (100 test cases)

Test #5:

score: 0
Accepted
time: 1522ms
memory: 3640kb

input:

100
-52 -13 72 44 58
79 -58 32 60 11
-50 21 75 95 65
-37 -61 21 -74 -40
0 -88 14 11 -49
10 -80 46 79 -17
75 -94 90 61 -34
-80 19 85 -7 -20
-72 42 56 67 -89
21 51 39 20 88
82 32 56 88 -82
3 51 31 -45 -53
50 12 91 9 46
-45 29 25 76 27
-19 -14 81 22 97
5 93 35 98 64
54 90 88 -100 63
-60 -18 81 -20 8
34...

output:

1
44 58 7 28
1
60 11 68 -28
1
95 65 22 42
1
-74 -40 -54 -49
1
11 -49 5 -75
1
79 -17 43 -48
0
61 -34
0
-7 -20
1
67 -89 -30 5
0
20 88
1
88 -82 82 -24
1
-45 -53 -10 23
0
9 46
1
76 27 -20 29
1
22 97 9 62
1
98 64 39 85
1
-100 63 -33 77
0
-20 8
1
62 16 46 51
1
-46 66 -79 -27
1
62 -91 -11 -54
1
-55 -54 73 ...

result:

ok correct (100 test cases)

Test #6:

score: 0
Accepted
time: 1665ms
memory: 3664kb

input:

100
-14 48 115 -133 160
80 40 30 181 139
114 -109 102 -111 -14
-51 175 113 40 -116
-44 -171 69 6 -128
18 -23 159 94 170
-150 71 199 -167 -181
82 173 50 -138 41
-27 -126 119 195 134
-129 16 169 -103 51
183 136 117 -196 54
25 61 27 166 12
-156 63 199 -8 -56
-143 138 31 -137 125
48 16 44 -83 37
150 -16...

output:

1
-133 160 -99 125
1
181 139 102 60
1
-111 -14 19 -72
1
40 -116 -18 67
0
6 -128
1
94 170 76 125
1
-167 -181 -167 -127
1
-138 41 40 146
1
195 134 53 -38
0
-103 51
1
-196 54 69 110
1
166 12 50 51
0
-8 -56
0
-137 125
1
-83 37 5 25
1
-71 -195 9 -183
1
-77 -188 -51 120
1
-88 135 -100 -179
0
170 90
1
-25 ...

result:

ok correct (100 test cases)

Test #7:

score: 0
Accepted
time: 1712ms
memory: 3588kb

input:

100
30 194 241 273 -11
476 -181 37 -18 -139
-162 496 295 113 250
-413 467 26 -100 312
-322 -120 423 -86 222
464 231 266 -421 497
249 -467 327 -183 -486
-316 486 468 -295 -286
92 141 487 -146 -13
108 -300 14 318 17
229 -180 49 -247 -464
-385 326 56 -493 62
-365 349 114 -258 293
44 -443 26 -139 -313
6...

output:

1
273 -11 217 42
1
-18 -139 439 -181
1
113 250 60 302
1
-100 312 -389 457
0
-86 222
1
-421 497 208 303
1
-183 -486 -77 -486
1
-295 -286 -316 18
0
-146 -13
1
318 17 115 -288
1
-247 -464 187 -205
1
-493 62 -408 275
1
-258 293 -264 297
1
-139 -313 23 -428
1
-458 -334 55 71
1
210 -353 304 215
0
-118 -26...

result:

ok correct (100 test cases)

Test #8:

score: 0
Accepted
time: 1565ms
memory: 3596kb

input:

100
411 -186 278 885 -994
-930 792 129 -912 -596
879 -250 54 312 -682
-712 -577 304 -473 409
109 -353 664 -141 -316
117 691 571 -217 166
-596 974 792 -326 630
-15 497 654 -575 -991
-714 -567 262 847 -440
182 29 60 -584 -920
-68 -858 810 -351 -901
-429 -633 975 -244 814
881 -213 818 -870 425
173 639 ...

output:

1
885 -994 546 -429
1
-912 -596 -930 663
1
312 -682 838 -285
1
-473 409 -643 -281
0
-141 -316
1
-217 166 -189 209
0
-326 630
1
-575 -991 -248 -114
1
847 -440 -453 -545
1
-584 -920 146 -19
0
-351 -901
1
-244 814 -305 334
1
-870 425 111 63
0
-124 917
1
-109 987 80 -268
1
-421 899 421 376
1
153 -591 68...

result:

ok correct (100 test cases)

Test #9:

score: 0
Accepted
time: 1854ms
memory: 3648kb

input:

100
190 562 152 560 564
-732 968 55 -887 965
-370 982 376 324 982
-263 -163 232 381 -165
-95 -654 238 258 -652
379 -43 668 -521 -36
884 782 580 267 786
-7 907 494 -802 908
970 -214 135 356 -209
410 40 139 173 42
-908 -832 24 -539 -835
806 -288 25 680 -296
-906 166 22 -873 165
-628 459 200 -122 454
-...

output:

1
560 564 342 562
1
-887 965 -787 968
1
324 982 6 982
1
381 -165 -31 -163
1
258 -652 143 -654
1
-521 -36 -289 -43
1
267 786 304 782
1
-802 908 -501 907
1
356 -209 835 -214
1
173 42 271 40
1
-539 -835 -884 -832
1
680 -296 781 -288
1
-873 165 -884 166
1
-122 454 -428 459
1
-717 -627 -764 -634
1
373 28...

result:

ok correct (100 test cases)

Test #10:

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

input:

100
885 -747 696 892 13
536 -416 299 532 74
639 295 250 636 20
532 406 91 524 208
-148 -392 337 -141 41
371 411 327 366 800
761 -461 50 758 -532
-712 -644 527 -720 -94
-724 -693 385 -731 -201
967 153 254 958 -328
-615 -291 390 -612 -950
-260 915 41 -258 136
-971 779 24 -974 -172
118 -106 509 109 -80...

output:

1
892 13 885 -51
1
532 74 536 -117
1
636 20 639 45
1
524 208 532 315
1
-141 41 -148 -55
1
366 800 371 738
1
758 -532 761 -511
1
-720 -94 -720 -118
1
-731 -201 -724 -308
1
958 -328 967 -101
1
-612 -950 -615 -681
1
-258 136 -260 874
1
-974 -172 -971 755
1
109 -805 118 -615
1
844 819 851 859
1
-230 629...

result:

ok correct (100 test cases)

Test #11:

score: 0
Accepted
time: 1801ms
memory: 3880kb

input:

100
-870 761 1681 -508 -1766
1437 -353 988 -96 558
-823 1649 579 285 -1783
1482 -257 84 -1412 894
1076 -1999 662 -1646 -548
-1596 779 108 1010 -1803
-1139 1322 1656 1833 -1498
-1950 -1093 1605 1813 1793
212 -107 1488 -1888 -1678
-1489 434 1415 -317 -1851
108 -1460 1947 457 1813
1762 -1366 1524 135 6...

output:

1
-508 -1766 -632 -903
1
-96 558 585 147
1
285 -1783 -655 1095
1
-1412 894 1404 -226
1
-1646 -548 489 -1693
1
1010 -1803 -1513 710
1
1833 -1498 64 184
1
1813 1793 -679 -113
1
-1888 -1678 -981 -996
1
-317 -1851 -851 -829
1
457 1813 305 477
1
135 600 794 -189
1
906 15 -1171 -210
1
795 1521 481 -196
1
...

result:

ok correct (100 test cases)

Test #12:

score: 0
Accepted
time: 1618ms
memory: 3740kb

input:

100
519 -610 764 1776 -610
-161 1052 223 -1545 1052
-423 1331 808 -1876 1326
167 1457 91 -31 1449
-1442 -1344 720 355 -1341
1703 1535 583 498 1544
245 519 1257 -1498 518
-242 147 1251 -1860 147
1702 1916 1069 35 1918
-849 1473 346 -1818 1472
1189 -647 170 1472 -656
-42 -87 182 240 -96
991 -1971 378 ...

output:

1
1776 -610 1283 -610
1
-1545 1052 -384 1052
1
-1876 1326 -1231 1331
1
-31 1449 76 1457
1
355 -1341 -722 -1344
1
498 1544 1120 1535
1
-1498 518 -1012 519
1
-1860 147 -1493 147
1
35 1918 633 1916
1
-1818 1472 -1195 1473
1
1472 -656 1359 -647
1
240 -96 140 -87
1
168 -1972 613 -1971
1
-711 -1275 -50 -1...

result:

ok correct (100 test cases)

Test #13:

score: 0
Accepted
time: 1696ms
memory: 3668kb

input:

100
1478 -111 204 1471 1077
-1137 303 132 -1135 145
1170 653 557 1174 -800
1508 -1843 129 1508 -597
1100 -19 804 1103 -864
-899 123 535 -906 738
-1027 -65 278 -1026 872
222 359 990 219 1424
-1996 -239 79 -1992 1034
1892 -887 978 1894 855
-599 -682 45 -601 -1452
-1198 969 128 -1198 1478
-1620 -955 14...

output:

1
1471 1077 1478 93
1
-1135 145 -1137 171
1
1174 -800 1170 96
1
1508 -597 1508 -1714
1
1103 -864 1100 -823
1
-906 738 -899 658
1
-1026 872 -1027 213
1
219 1424 222 1349
1
-1992 1034 -1996 -160
1
1894 855 1892 91
1
-601 -1452 -599 -727
1
-1198 1478 -1198 1097
1
-1619 -1718 -1620 -1102
1
965 268 960 -...

result:

ok correct (100 test cases)

Test #14:

score: 0
Accepted
time: 1857ms
memory: 3880kb

input:

100
-3385 -1108 801 286 -1717
347 4287 3702 -2012 -239
-2842 1631 1554 -4783 2262
4930 1666 3142 3983 -2482
-4404 -1160 3440 -1249 4708
-632 -557 1489 930 -4322
-549 -2060 1450 -2537 2605
-1824 4416 4330 -3635 -3640
2979 -3339 1423 -2598 -1648
-4079 1254 2795 1612 2342
3409 -2881 4605 2283 800
-533 ...

output:

1
286 -1717 -2594 -1234
1
-2012 -239 -1356 1000
1
-4783 2262 -4320 2111
1
3983 -2482 4230 -1397
1
-1249 4708 -2781 1873
1
930 -4322 -68 -1935
1
-2537 2605 -1110 -723
1
-3635 -3640 -2785 194
1
-2598 -1648 1617 -2927
1
1612 2342 -1333 1775
0
2283 800
1
-1768 -2568 -1527 -3049
1
1332 -4940 -4795 4640
1...

result:

ok correct (100 test cases)

Test #15:

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

input:

100
4838 -3288 1574 2001 -3280
4302 -3171 20 4434 -3179
1645 -2971 11 1689 -2974
231 -2343 2645 3771 -2337
-3038 3521 1147 -935 3516
-1139 2837 852 -3546 2842
173 2057 166 354 2064
-2660 -645 1843 -4543 -640
-3695 -4513 629 -2291 -4510
-2258 -4067 1240 -856 -4065
316 884 355 -2716 884
-3417 2961 518...

output:

1
2001 -3280 3264 -3288
1
4434 -3179 4322 -3171
1
1689 -2974 1656 -2971
1
3771 -2337 2876 -2343
1
-935 3516 -1891 3521
1
-3546 2842 -1991 2837
1
354 2064 338 2064
1
-4543 -640 -4503 -645
1
-2291 -4510 -3066 -4513
1
-856 -4065 -1018 -4067
1
-2716 884 -39 884
1
-657 2970 -2899 2961
1
681 4364 343 4367...

result:

ok correct (100 test cases)

Test #16:

score: 0
Accepted
time: 1928ms
memory: 3664kb

input:

100
-4633 -2041 1986 -4631 2439
-4880 4624 28 -4872 4697
-1457 -2643 1737 -1456 -4917
1015 -1805 2204 1011 -4481
-3984 4419 352 -3978 4015
4254 -1414 2569 4263 -4810
-1031 1275 464 -1030 2952
4119 -1206 4596 4125 3748
-4511 -3516 1360 -4520 -435
-927 -276 2080 -933 -4996
1842 3457 31 1834 2536
-804 ...

output:

1
-4631 2439 -4633 -55
1
-4872 4697 -4880 4652
1
-1456 -4917 -1457 -4380
1
1011 -4481 1015 -4009
1
-3978 4015 -3984 4067
1
4263 -4810 4254 -3983
1
-1030 2952 -1031 1739
1
4125 3748 4119 3390
1
-4520 -435 -4511 -2156
1
-933 -4996 -927 -2356
1
1834 2536 1842 3426
1
-807 -580 -804 -97
1
-2204 3891 -220...

result:

ok correct (100 test cases)

Test #17:

score: -100
Time Limit Exceeded

input:

100
723 6148 6508 -4871 -7883
-6934 -2184 5218 -9448 -7089
7488 -6851 4397 5228 -4063
5219 602 6560 7100 -7395
7897 8717 8573 9453 -8398
-3861 -4510 7092 4342 -7411
232 5977 1965 -2860 6405
-4347 -1385 8693 -6598 1817
-5110 -7662 9020 1753 6101
-5427 -8770 1024 7195 -3393
9548 -6485 8149 9903 3494
4...

output:


result: