QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#42825#4423. AMPPZ in the times of diseasezghtyarecrenjWA 3673ms42904kbC++171.0kb2022-08-04 07:51:172022-08-04 07:51:19

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-04 07:51:19]
  • 评测
  • 测评结果:WA
  • 用时:3673ms
  • 内存:42904kb
  • [2022-08-04 07:51:17]
  • 提交

answer

#include <bits/stdc++.h>

typedef long long ll;
typedef std::pair<int, int> point;
const ll inf = 1e18;
const int N = 2e6 + 5;
#define x first
#define y second

int n, k, init[32], res[N];
ll dis[N];
point a[N];

inline ll dist(point a, point b) {
	return 1ll * (a.x - b.x) * (a.x - b.x) + 1ll * (a.y - b.y) * (a.y - b.y);
}

void solve() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; ++i) scanf("%d%d", &a[i].x, &a[i].y);
	memset(dis, 0x3f, sizeof(ll) * n);
    for (int i = 0; i < k; ++i) {
    	for (int j = 1; j < n; ++j) if (dis[j] > dis[init[i]]) init[i] = j;
        for (int j = 0; j < n; ++j) dis[j] = std::min(dis[j], dist(a[j], a[init[i]]));
    }
    for (int i = 0; i < n; ++i) {
        ll mn = inf;
        for (int j = 0; j < k; ++j) {
            ll tmp = dist(a[i], a[init[j]]);
            if (tmp < mn) res[i] = j + 1, mn = tmp;
        }
    }
    for (int i = 0; i < n; ++i) printf("%d ", res[i]); puts("");
}

int main() {
	int T; scanf("%d", &T);
    while (T--) solve();
    return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 3309ms
memory: 10072kb

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: 3614ms
memory: 42848kb

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: 3493ms
memory: 42868kb

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: 3673ms
memory: 42904kb

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: -100
Wrong Answer
time: 3524ms
memory: 7872kb

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:

wrong answer there are no students in #19 (test case 74)