QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#211409#868. Friendship Circlesucup-team1004AC ✓48ms12312kbC++142.9kb2023-10-12 15:56:042023-10-12 15:56:05

Judging History

This is the latest submission verdict.

  • [2023-10-12 15:56:05]
  • Judged
  • Verdict: AC
  • Time: 48ms
  • Memory: 12312kb
  • [2023-10-12 15:56:04]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<typename T>
ostream& operator << (ostream &out,const vector<T>&x){
	if(x.empty())return out<<"[]";
	out<<'['<<x[0];
	for(int len=x.size(),i=1;i<len;i++)out<<','<<x[i];
	return out<<']';
}
template<typename T>
vector<T> ary(const T *a,int l,int r){
	return vector<T>{a+l,a+1+r};
}
template<typename T>
void debug(T x){
	cerr<<x<<'\n';
}
template<typename T,typename ...S>
void debug(T x,S ...y){
	cerr<<x<<' ',debug(y...);
}
using Real=long double;
const int N=1e5+10;
const Real INF=1e12;
struct vec{
	Real x,y;
	vec(Real a=0,Real b=0):x(a),y(b){}
};
ostream& operator << (ostream &out,const vec &x){
	return out<<'('<<x.x<<','<<x.y<<')';
}
vec operator - (const vec &a,const vec &b){
	return vec(a.x-b.x,a.y-b.y);
}
vec operator + (const vec &a,const vec &b){
	return vec(a.x+b.x,a.y+b.y);
}
vec operator * (const vec &a,const Real &k){
	return vec(a.x*k,a.y*k);
}
Real dot(const vec &a,const vec &b){
	return a.x*b.x+a.y*b.y;
}
Real cross(const vec &a,const vec &b){
	return a.x*b.y-a.y*b.x;
}
vec common(vec a,vec b,vec x,vec y){
	Real p=cross(b-x,a-x),q=cross(a-y,b-y);
	return x*(q/(p+q))+y*(p/(p+q));
}
int where(const vec &a){
	if(!a.y)return a.x>0?0:2;
	else return a.y>0?1:3;
}
bool cmp(const vec &a,const vec &b){
	int p=where(a),q=where(b);
	return p^q?p<q:cross(a,b)>0;
}
int T,n,Ox,Oy;
struct half{
	vec s,t;
	int id;
}a[N];
ostream& operator << (ostream &out,const half &x){
	return out<<'{'<<x.id<<':'<<x.s<<"->"<<x.t<<'}';
}
int q[N],ans[N];
bool chk(int i,int j,int k){
	vec x=a[i].t-a[i].s,y=a[j].t-a[j].s,z=a[k].t-a[k].s;
	if(cross(x,y)<=0||cross(y,z)<=0)return 1;
	return cross(a[i].t-a[i].s,common(a[j].s,a[j].t,a[k].s,a[k].t)-a[i].s)>0;
}
int TT;
void get(){
	scanf("%d%d%d",&n,&Ox,&Oy),n--;
	for(int i=1,x,y;i<=n;i++){
		scanf("%d%d",&x,&y);
		x-=Ox,y-=Oy;
		a[i].s=vec(x,y);
		a[i].t=a[i].s+vec(-y,x);
		a[i].id=i;
	}
	// if(++TT==5){
	// 	cout<<n<<endl<<"0 0"<<endl;
	// 	for(int i=1;i<=n;i++){
	// 		printf("%.Lf %.Lf\n",a[i].s.x,a[i].s.y);
	// 	}
	// 	exit(0);
	// }
	// a[++n]={vec(-INF,-INF),vec(INF,-INF),0};
	// a[++n]={vec(INF,-INF),vec(INF,INF),0};
	// a[++n]={vec(INF,INF),vec(-INF,INF),0};
	// a[++n]={vec(-INF,INF),vec(-INF,-INF),0};
	sort(a+1,a+1+n,[](half x,half y){
		return cmp(x.t-x.s,y.t-y.s);
	});
	// debug(ary(a,1,n));
	// debug(chk(1,2,3));
	int L=1,R=0;
	for(int i=1;i<=n;i++){
		for(;L<R&&!chk(q[R-1],q[R],i);R--);
		for(;L<R&&!chk(i,q[L],q[L+1]);L++);
		q[++R]=i;
	}
	for(;L+1<R&&!chk(q[R-1],q[R],q[L]);R--);
	fill(ans+1,ans+1+n,0);
	for(int i=L;i<=R;i++)ans[a[q[i]].id]=1;
	// for(int i=L;i<=R;i++){
	// 	debug(a[q[i]]);
	// }
	int cnt=accumulate(ans+1,ans+1+n,0);
	// if(T>10)return;
	printf("%d",cnt);
	for(int i=1;i<=n;i++){
		if(ans[i])printf(" %d",i);
	}
	puts("");
}
int main(){
	for(scanf("%d",&T);T--;)get();
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 11520kb

input:

2
4
1 0
3 1
3 -2
7 0
5
0 0
-2 -1
2 2
-2 10
-1 11

output:

2 1 2
3 1 2 3

result:

ok 7 numbers

Test #2:

score: 0
Accepted
time: 19ms
memory: 12212kb

input:

10000
10
132243110 -894263225
-965927366 756806080
-563126858 -401644076
-528090722 -199265042
-184232391 -184423675
-346777300 -583114791
624815460 788278140
543172921 980159251
-143672624 674688477
-393343296 525780596
9
64745555 827730910
-665070184 -152609349
-905275127 -345568169
-949821348 -84...

output:

3 4 5 6
5 1 4 6 7 8
1 1
3 1 2 3
2 2 5
3 1 2 3
6 1 2 3 4 5 6
5 1 2 3 4 9
4 1 2 3 4
6 1 2 3 4 5 9
2 1 2
3 1 4 6
5 2 4 5 6 7
4 1 2 4 5
3 1 2 3
4 1 2 3 6
3 1 6 8
1 1
2 1 2
5 1 3 4 6 7
5 1 2 4 5 6
3 2 3 4
4 1 3 4 7
4 1 3 7 9
3 3 4 5
4 3 4 6 8
5 1 3 4 6 7
3 1 2 3
2 2 3
3 2 5 6
3 1 2 3
3 2 3 4
4 2 5 6 8
3 ...

result:

ok 41282 numbers

Test #3:

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

input:

1000
53
981976744 508887295
-580496145 -368111494
-40659809 382477779
847997458 -445652992
-709716808 -129570248
-313838973 349710333
-876139130 111370588
320646104 -950965389
548578750 -574361293
-799802872 957309031
127037627 -53366027
-477625360 229044322
-283654405 965960603
-83080242 -489998095...

output:

4 34 40 41 47
6 9 14 19 27 32 67
5 30 37 44 46 48
5 20 27 29 30 38
6 8 11 13 18 23 43
4 5 10 13 89
7 17 26 32 52 70 72 80
5 1 2 3 4 5
4 31 52 57 66
7 9 10 14 16 21 26 27
7 1 5 6 8 9 10 11
8 9 21 22 24 26 27 33 37
7 7 9 28 35 54 55 65
4 14 26 30 62
4 1 2 8 11
6 8 14 36 48 51 76
4 14 16 20 57
8 39 41 ...

result:

ok 6180 numbers

Test #4:

score: 0
Accepted
time: 36ms
memory: 12252kb

input:

100
1000
154123590 -195643584
906998887 659267250
-861981209 -248731154
156410684 -366976998
636150181 849111460
212242101 726773347
-441502446 718696955
-726340230 -438559100
523592711 -829247123
-429817421 -907222370
-743602659 503290332
48678284 954678898
819529524 103315724
-803643464 249247717
...

output:

5 231 574 863 946 983
5 95 148 373 491 578
6 266 533 717 724 732 829
8 8 26 126 416 647 733 734 831
7 209 630 680 725 926 931 980
7 46 203 385 572 759 798 992
5 234 267 322 395 722
5 234 589 597 724 802
7 77 286 508 527 578 629 949
5 210 754 778 829 933
7 76 214 299 300 746 935 951
6 468 517 624 722...

result:

ok 706 numbers

Test #5:

score: 0
Accepted
time: 17ms
memory: 11528kb

input:

50
1000
585441498 537521779
-299019164 -926606017
955725480 -237915475
-999645057 192074481
-543154139 -494983865
-509026736 837773604
548176004 89171630
-985096027 659257966
-821797427 -327883708
571023968 785197466
-650635428 138842844
-81541899 267997223
-369325984 38167872
541905647 -15789881
-3...

output:

6 268 310 339 486 653 770
5 211 282 365 411 636
5 123 209 472 585 766
5 254 393 425 798 927
6 210 570 578 641 908 928
6 129 154 513 717 812 933
6 172 377 476 518 532 716
5 143 417 442 754 888
7 107 145 188 390 567 643 710
8 40 367 386 430 508 694 872 901
5 13 62 335 508 750
4 55 378 408 459
5 90 778...

result:

ok 339 numbers

Test #6:

score: 0
Accepted
time: 11ms
memory: 11464kb

input:

20
1000
949240525 985538611
750623973 -891600358
486266434 -795975822
590585910 -31981534
-330952737 -267486074
161784968 -322523021
570490959 -530866569
-87914744 -576652443
-220687519 -57167345
679521862 -251619499
-274604922 -966571426
-225598794 395382053
779474773 -750165705
-52945103 180963514...

output:

6 116 178 389 511 847 863
6 41 218 430 668 804 951
5 520 526 575 818 914
6 100 127 329 412 551 597
5 50 131 256 361 978
9 47 57 383 446 464 523 584 605 683
5 50 77 488 637 998
7 86 186 208 230 364 639 842
5 87 237 383 590 907
4 229 844 870 979
5 99 509 571 760 945
6 101 108 174 571 681 917
6 115 271...

result:

ok 136 numbers

Test #7:

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

input:

20
1000
-167643347 854054751
-950562769 839061824
-534384313 748502955
-829385211 -983764842
744757226 14818109
-309178784 439036722
-196741654 -211072840
-425752933 -499204526
207784396 947337110
847919880 892677446
-982316981 -346423648
-855715476 -942552076
801788630 -174822793
660149118 76138837...

output:

6 227 232 391 636 754 979
6 229 291 542 673 683 944
5 145 279 435 982 997
5 90 279 338 368 567
4 1 279 387 953
7 54 189 281 466 633 919 955
6 112 206 559 683 897 935
6 17 399 853 938 939 968
7 164 232 535 584 629 651 762
9 19 294 331 417 461 654 770 918 919
8 211 401 419 444 571 613 682 951
6 242 29...

result:

ok 146 numbers

Test #8:

score: 0
Accepted
time: 11ms
memory: 12184kb

input:

20
1000
-989559922 -717620596
788441976 9915493
-700259251 292981732
900386772 654386442
965691382 297122291
70114359 55372274
-404165756 373562106
-498749906 723467583
-508967882 -898415332
426383307 331941687
869779472 273724130
-340607967 279322308
529135191 695487416
-626756661 192070132
3863746...

output:

4 182 471 575 904
6 105 212 248 352 535 679
8 50 307 386 464 547 652 909 952
7 27 180 288 485 821 892 962
6 48 297 437 465 782 876
8 17 81 167 409 438 818 918 930
5 267 363 409 808 926
7 157 249 471 659 662 663 941
6 209 276 547 624 914 926
6 212 235 436 447 651 964
5 54 285 444 455 517
4 215 311 69...

result:

ok 140 numbers

Test #9:

score: 0
Accepted
time: 11ms
memory: 11404kb

input:

20
1000
188523502 855928248
-617777470 35544971
279090002 -722348004
630158756 -297396866
891658241 579426473
744374799 -888100686
238667038 693355835
-836588095 505948204
-375463263 106089122
594781325 331014439
721875924 -251352284
174499542 -203836013
551449048 420573432
381304856 -932537711
-440...

output:

7 189 303 443 746 781 871 994
4 218 623 820 902
5 60 476 828 830 894
7 177 274 406 441 443 553 798
5 123 261 428 610 735
6 86 334 443 532 631 846
6 203 360 503 526 582 707
8 127 162 449 678 684 742 834 993
6 171 184 227 521 561 780
6 103 164 264 407 610 670
8 104 112 157 165 174 558 714 763
7 4 33 1...

result:

ok 143 numbers

Test #10:

score: 0
Accepted
time: 21ms
memory: 11632kb

input:

10
9172
912539639 -412602596
-170683029 -339514159
240423405 682241967
-908332244 -739591132
49189079 245180429
804822663 -237424332
41789403 -94091238
485092068 920876789
-78296892 313466107
964497553 -653082143
385178750 -111453794
-446173892 688484468
-25448547 -246188240
-995961733 -332340305
87...

output:

6 167 2692 3047 6627 6672 8899
5 102 116 149 164 246
7 15 33 57 65 72 84 117
8 791 1421 2972 3641 4168 7769 7781 9159
6 520 917 1123 1445 2028 2378
5 14 1278 2039 2132 2134
8 1760 2053 2143 2198 4090 5070 5152 5491
6 2 5 7 21 29 190
5 203 415 2511 4767 5208
6 536 4092 4527 5721 7536 7759

result:

ok 72 numbers

Test #11:

score: 0
Accepted
time: 18ms
memory: 11836kb

input:

1
51976
218479545 -323200417
138714781 -709381932
-462379498 450920276
-307976979 426884097
-520439495 892377325
-914912579 -171317468
-862054514 -623904272
-933747975 -562729385
-669135197 -807350552
760790512 -527095882
738243496 -806739291
-377065000 -514514972
-219081738 72062649
648396616 -8346...

output:

4 5729 17362 23622 42866

result:

ok 5 number(s): "4 5729 17362 23622 42866"

Test #12:

score: 0
Accepted
time: 20ms
memory: 11792kb

input:

1
39560
86995686 270580137
459311555 564934617
522290767 180692260
-114536095 -792373236
56831984 126446276
-153352835 766482623
-542260784 -696901245
-856300058 720518338
630336553 -638952534
-945169439 765192059
-936576022 -291631782
844809383 -492201115
-493995722 785156870
933854180 43810956
707...

output:

5 69 9765 13467 22962 39047

result:

ok 6 numbers

Test #13:

score: 0
Accepted
time: 19ms
memory: 11820kb

input:

1
47636
-339455470 864360691
189973737 -455716129
-228197753 -89535757
-771352107 -866406376
44168870 800706716
-537017283 854025817
337341457 965260566
-778852141 -851009748
489616815 939510892
-95839790 912255808
-316428244 518443023
361651062 -469887258
376314486 -501748908
-485720959 362492564
8...

output:

5 12279 15431 28553 37024 44937

result:

ok 6 numbers

Test #14:

score: 0
Accepted
time: 14ms
memory: 11652kb

input:

1
35220
-765906626 308398140
-639172594 -621591067
-683718976 785460418
866799177 -645472221
326473052 -230065548
519509756 -503141389
362167890 892263593
443819968 432237974
-210911435 -892091090
-656575549 -940680444
-841504658 -406640955
-416474555 -742540697
-753375305 211345313
-465104610 91239...

output:

5 431 5596 18791 22640 34886

result:

ok 6 numbers

Test #15:

score: 0
Accepted
time: 14ms
memory: 11992kb

input:

1
33050
-897390485 607211398
-908510412 357758186
300951289 220265106
-84984131 -719505361
903744531 149227595
-718930500 434658701
-758229869 554425404
521267885 -284514303
-56663876 981339632
-362535501 911416009
-221356881 108466554
245591317 -720226840
-472999689 -780593170
-179647045 969729701
...

output:

6 2785 7705 16069 18056 21113 28584

result:

ok 7 numbers

Test #16:

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

input:

1
20634
-764033129 346216144
-882880935 -662892560
-154569934 -609771423
-741800143 -498571206
-813951287 823488035
337596540 -627541208
-438436139 776395727
303748506 -445976981
-757192126 -850262350
781761444 203703949
398790897 623574063
-532534300 -697912983
-747913673 -67498949
-453997992 -7115...

output:

6 1794 2579 11159 11783 18267 20116

result:

ok 7 numbers

Test #17:

score: 0
Accepted
time: 46ms
memory: 11888kb

input:

1
100000
-646797560 218479545
-323200417 138714781
-709381932 -462379498
450920276 -307976979
426884097 -520439495
892377325 -914912579
-171317468 -862054514
-623904272 -933747975
-562729385 -669135197
-807350552 760790512
-527095882 738243496
-806739291 -377065000
-514514972 -219081738
72062649 648...

output:

5 37026 53371 56617 66977 78931

result:

ok 6 numbers

Test #18:

score: 0
Accepted
time: 42ms
memory: 11884kb

input:

1
100000
236318568 86995686
270580137 459311555
564934617 522290767
180692260 -114536095
-792373236 56831984
126446276 -153352835
766482623 -542260784
-696901245 -856300058
720518338 630336553
-638952534 -945169439
765192059 -936576022
-291631782 844809383
-492201115 -493995722
785156870 933854180
4...

output:

7 6732 15569 33589 38485 70033 72318 90876

result:

ok 8 numbers

Test #19:

score: 0
Accepted
time: 46ms
memory: 12312kb

input:

1
100000
-290630712 -339455470
864360691 189973737
-455716129 -228197753
-89535757 -771352107
-866406376 44168870
800706716 -537017283
854025817 337341457
965260566 -778852141
-851009748 489616815
939510892 -95839790
912255808 -316428244
518443023 361651062
-469887258 376314486
-501748908 -485720959...

output:

6 35537 41042 47921 53983 77048 82612

result:

ok 7 numbers

Test #20:

score: 0
Accepted
time: 38ms
memory: 11832kb

input:

1
100000
592485416 -765906626
308398140 -639172594
-621591067 -683718976
785460418 866799177
-645472221 326473052
-230065548 519509756
-503141389 362167890
892263593 443819968
432237974 -210911435
-892091090 -656575549
-940680444 -841504658
-406640955 -416474555
-742540697 -753375305
211345313 -4651...

output:

8 11280 18791 26082 33626 39077 39842 54691 77606

result:

ok 9 numbers

Test #21:

score: 0
Accepted
time: 48ms
memory: 11900kb

input:

1
100000
-229431160 -897390485
607211398 -908510412
357758186 300951289
220265106 -84984131
-719505361 903744531
149227595 -718930500
434658701 -758229869
554425404 521267885
-284514303 -56663876
981339632 -362535501
911416009 -221356881
108466554 245591317
-720226840 -472999689
-780593170 -17964704...

output:

5 9509 13914 25880 27743 78913

result:

ok 6 numbers

Test #22:

score: 0
Accepted
time: 46ms
memory: 11816kb

input:

1
100000
653684968 -764033129
346216144 -882880935
-662892560 -154569934
-609771423 -741800143
-498571206 -813951287
823488035 337596540
-627541208 -438436139
776395727 303748506
-445976981 -757192126
-850262350 781761444
203703949 398790897
623574063 -532534300
-697912983 -747913673
-67498949 -4539...

output:

4 11518 18915 86428 93084

result:

ok 5 number(s): "4 11518 18915 86428 93084"

Test #23:

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

input:

1
100
0 0
1000000000 0
998369103 57088810
993481735 113991409
985353835 170522192
974011916 226496767
959492973 281732556
941844363 336049393
921123653 389270106
897398428 441221101
870746077 491732924
841253532 540640817
809016994 587785252
774141610 633012453
736741137 676174900
696937568 71713180...

output:

99 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

result:

ok 100 numbers

Test #24:

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

input:

1
1000
0 0
1000000000 0
999980649 6220935
999922599 12441630
999825852 18661843
999690411 24881334
999516282 31099862
999303471 37317186
999051986 43533067
998761838 49747262
998433037 55959532
998065597 62169637
997659531 68377336
997214855 74582388
996731586 80784554
996209744 86983594
995649347 9...

output:

999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 ...

result:

ok 1000 numbers

Test #25:

score: 0
Accepted
time: 7ms
memory: 11512kb

input:

1
10000
0 0
1000000000 0
999999803 627690
999999212 1255381
999998227 1883071
999996848 2510760
999995075 3138449
999992908 3766136
999990347 4393821
999987392 5021505
999984043 5649187
999980300 6276867
999976163 6904544
999971632 7532218
999966707 8159890
999961388 8787558
999955675 9415223
999949...

output:

9999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...

result:

ok 10000 numbers

Test #26:

score: 0
Accepted
time: 45ms
memory: 12236kb

input:

1
100000
0 0
1000000000 0
999999998 62825
999999992 125651
999999982 188476
999999968 251302
999999950 314127
999999928 376953
999999903 439778
999999873 502604
999999840 565430
999999802 628255
999999761 691081
999999715 753906
999999666 816732
999999613 879557
999999555 942383
999999494 1005208
99...

output:

99999 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 10...

result:

ok 100000 numbers