QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#73658#4423. AMPPZ in the times of diseasechenqingboruiAC ✓7696ms81700kbC++141.0kb2023-01-27 13:46:592023-01-27 13:47:02

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-01-27 13:47:02]
  • 评测
  • 测评结果:AC
  • 用时:7696ms
  • 内存:81700kb
  • [2023-01-27 13:46:59]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
using namespace std;
int T,n,k,c[2002002],vis[2002002],x[2002002],y[2002002],minv[2002002];
int dis(int a,int b)
{
    return (x[a]-x[b])*(x[a]-x[b])+(y[a]-y[b])*(y[a]-y[b]);
}
void calc(int x,int bl)
{
	for(int j=1;j<=n;j++)
    {
		if(vis[j])
            continue;
		int d=dis(x,j);
		if(d<minv[j])
		{
		    minv[j]=d;
		    c[j]=bl;
        }
	}
}
signed main()
{
    cin>>T;
	for(int ww=1;ww<=T;ww++)
    {
        cin>>n>>k;
		for(int i=1;i<=n;i++)
        {
			minv[i]=1ll<<60;
            c[i]=0;
            vis[i]=0;
            cin>>x[i]>>y[i];
		}
		c[1]=1;
		vis[1]=1;
		int lst=1;
		calc(lst,1);
		for(int i=2;i<=k;i++)
        {
			int nw=0;
			for(int j=1;j<=n;j++)
			{
				if(vis[j])
                    continue;
				if(minv[j]>minv[nw])
                    nw=j;
			}
			c[nw]=i;
			vis[nw]=1;
			lst=nw;
			calc(nw,i);
		}
		for(int i=1;i<=n;i++)
            cout<<c[i]<<' ';
        puts("");
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 6681ms
memory: 18440kb

input:

100
100000 20
270505 510725
245104 76414
131477 992924
781607 895592
562469 622976
564354 637966
980036 112090
522903 687218
113871 977855
6615 123673
13847 347618
657794 165707
420561 183995
11367 136391
507836 694877
985069 105115
774110 486921
14319 338715
774937 118145
981468 99089
803866 491315...

output:

1 11 4 3 19 19 2 8 4 5 9 10 7 5 8 2 6 9 17 2 6 10 13 3 12 1 7 16 13 19 11 10 14 12 16 3 17 7 3 14 14 9 11 1 19 13 1 20 6 20 13 20 10 13 13 18 5 1 5 13 13 17 18 9 3 7 17 16 12 17 14 10 16 12 5 10 17 6 18 15 3 2 4 6 4 9 7 12 20 6 11 19 19 13 13 3 6 12 2 13 6 1 5 1 5 13 5 7 17 6 12 14 13 12 8 20 19 13 ...

result:

ok ac (100 test cases)

Test #2:

score: 0
Accepted
time: 7696ms
memory: 81700kb

input:

5
2000000 20
128546949 27937564
245921588 62819439
245938747 62819439
245920165 62819440
245940996 62819441
245919462 62819441
245943717 62819443
245945427 62819445
245947161 62819447
245947035 62819447
245913847 62819447
245911321 62819450
245910715 62819451
245908052 62819455
245953333 62819457
24...

output:

1 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 14 1...

result:

ok ac (5 test cases)

Test #3:

score: 0
Accepted
time: 6422ms
memory: 81516kb

input:

5
2000000 20
938915 14534
939099 14534
938896 14534
938968 14534
939120 14534
938967 14534
939092 14534
939047 14534
939083 14534
938959 14534
938980 14534
939094 14534
939096 14534
939158 14534
939129 14534
939050 14534
939146 14534
939067 14534
938953 14534
939118 14534
939174 14534
938957 14534
9...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok ac (5 test cases)

Test #4:

score: 0
Accepted
time: 6664ms
memory: 81636kb

input:

5
1999992 20
714274 363953
4097901 6999896
4285652 7069412
672239 571422
408343 714278
4285652 6512757
995296 428566
4066535 6571329
4285652 6503633
4428508 7305200
1502570 714278
350759 714278
4078994 6999896
4285652 6566018
882958 428566
411620 714278
4085106 6999896
4285652 6530080
4142796 684433...

output:

1 20 11 14 6 9 17 16 9 2 4 6 20 9 17 6 20 9 15 4 2 18 16 2 11 11 18 20 4 3 16 17 18 14 11 18 3 3 11 14 6 4 16 9 15 16 3 14 20 14 6 9 17 3 1 16 9 9 16 14 17 11 14 2 16 15 3 4 3 16 6 4 9 16 2 14 4 18 17 18 10 11 14 10 20 1 16 4 17 9 20 4 6 3 2 9 3 9 6 4 15 4 14 16 18 11 9 20 18 18 6 4 10 3 10 14 16 18...

result:

ok ac (5 test cases)

Test #5:

score: 0
Accepted
time: 7009ms
memory: 11560kb

input:

98934
43 19
139544 85155
814904 5788
529650 268672
283948 536120
269963 210844
141436 82366
83187 749015
517204 336252
313961 432803
609446 700082
75325 746905
269976 218742
262201 982244
267097 970940
240151 822124
603197 913571
245406 817164
136898 78897
540853 274671
509382 335902
911470 765473
1...

output:

1 4 19 8 11 1 18 5 16 9 18 11 10 10 14 6 14 1 19 5 2 1 6 19 17 5 3 9 13 3 9 6 3 13 11 7 12 2 6 11 15 6 16 
1 15 17 6 2 14 4 17 6 4 19 18 3 13 1 5 7 4 7 5 15 14 5 11 13 4 1 12 18 6 5 8 7 2 10 11 5 8 13 9 14 11 8 19 6 13 5 16 18 18 4 9 10 7 16 13 16 5 4 2 12 8 11 18 5 17 10 17 11 9 9 6 5 13 1 3 
1 9 2...

result:

ok ac (98934 test cases)

Test #6:

score: 0
Accepted
time: 7401ms
memory: 81544kb

input:

5
2000000 20
797234517 492602938
798908045 502327723
792452167 502906629
798928689 489396948
788980587 490810854
799097890 494409757
802136723 493677251
798645177 497015697
788761604 495701224
794885101 501374539
806251682 495921503
794079841 483699742
797040968 499798682
804797434 501060369
8094369...

output:

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ...

result:

ok ac (5 test cases)

Test #7:

score: 0
Accepted
time: 1727ms
memory: 5400kb

input:

100000
49 3
184136 65720
77810 18746
185003 61402
190816 51862
81874 16192
199764 65637
84958 7413
196301 60803
75931 6532
76068 9903
74087 524
188023 67224
67425 5134
71213 3955
78196 9061
73745 132
84239 12547
69698 611
185262 60938
189186 65907
85093 5693
73581 15566
197267 65267
67120 5883
84736...

output:

1 3 1 1 3 1 3 1 3 3 3 1 3 3 3 3 3 3 1 1 3 3 1 3 3 3 3 3 1 3 3 1 3 3 1 2 1 3 2 3 1 1 3 1 1 3 3 3 3 
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 3 2 2 3 2 2 2 2 2 3 2 2 2 2 
1 1 1 3 3 2 2 2 2 
1 1 1 1 1 1 3 3 3 3 3 2 2 2 2 2 2 2 2 2 2 
1 1 2 2 1 2 1 1 2 2 2 2 1 2 1 1 2 2 1 ...

result:

ok ac (100000 test cases)

Extra Test:

score: 0
Extra Test Passed