QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#42453 | #4423. AMPPZ in the times of disease | Antistar | WA | 5814ms | 4608kb | C++20 | 1.2kb | 2022-08-02 14:57:19 | 2022-08-02 14:57:21 |
Judging History
answer
#include <bits/stdc++.h>
#include <cstdio>
#include <vector>
using namespace std;
using ll = long long;
const ll INF = 8e18;
ll dis(int x1, int y1, int x2, int y2) {
return 1ll * (x2 - x1) * (x2 - x1) + 1ll * (y2 - y1) * (y2 - y1);
}
void Main() {
int n, K;
scanf("%d%d", &n, &K);
vector<int> x(n), y(n);
for (int i = 0; i < n; i++) {
scanf("%d%d", &x[i], &y[i]);
}
vector<int> s;
vector<int> vis(n);
vis[0] = 1;
s.push_back(0);
for (int rnd = 2; rnd <= K; rnd++) {
pair<ll, int> all = {0, -1};
for (int i = 0; i < n; i++) {
pair<ll, int> res = {INF, -1};
if (!vis[i]) {
for (auto j : s)
res = min(res, {dis(x[i], y[i], x[j], y[j]), j});
all = max(all, {res.first, i});
}
}
vis[all.second] = 1;
s.push_back(all.second);
}
for (auto v : s)
cout << v << " ";
cout << endl;
for (int i = 0; i < n; i++) {
pair<ll, int> res = {INF, -1};
for (int j = 0; j < K; j++)
res = min(res, {dis(x[i], y[i], x[s[j]], y[s[j]]), j});
printf("%d ", res.second + 1);
}
}
int main() {
int T;
scanf("%d", &T);
while (T--) {
Main();
}
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 5814ms
memory: 4608kb
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:
0 43798 32754 36692 80266 59359 68822 59996 16498 25413 63275 41676 20648 2864 41937 72178 35906 85711 90614 77419 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 ...
result:
wrong answer Integer 0 violates the range [1, 20] (test case 1)