QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#139116 | #4423. AMPPZ in the times of disease | 8BQube# | AC ✓ | 6962ms | 42700kb | C++20 | 1.4kb | 2023-08-12 17:55:03 | 2023-08-12 17:55:05 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define X first
#define Y second
#define SZ(a) ((int)a.size())
#define pb push_back
#define ALL(v) v.begin(), v.end()
pll operator-(const pll &a, const pll &b) { return pll(a.X - b.X, a.Y - b.Y); }
ll dot(const pll &a, const pll &b) { return a.X * b.X + a.Y * b.Y; }
ll abs2(const pll &a) { return dot(a, a); }
const ll MAXC = 2e18;
pll arr[2000005], leader[25];
int num[2000005];
void solve() {
int n, k;
cin >> n >> k;
for (int i = 1; i <= n; ++i)
cin >> arr[i].X >> arr[i].Y;
auto check = [&](ll mid) {
fill_n(num + 1, n, 0);
int tp = 0;
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= tp; ++j)
if (abs2(arr[i] - leader[j]) <= mid) {
num[i] = j;
break;
}
if (!num[i]) leader[++tp] = arr[i], num[i] = tp;
if (tp >= k + 1) return false;
}
return true;
};
ll l = -1, r = MAXC;
while (r - l > 1) {
ll mid = (l + r) >> 1;
if (check(mid)) r = mid;
else l = mid;
}
check(r);
for (int i = 1; i <= n; ++i)
cout << num[i] << " \n"[i == n];
}
int main() {
ios::sync_with_stdio(0), cin.tie(0);
int t;
cin >> t;
while (t--) {
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 5880ms
memory: 8088kb
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 2 3 4 5 5 6 7 3 8 9 10 11 8 7 6 12 9 13 6 12 10 14 4 15 1 11 16 14 5 2 10 17 15 16 4 13 11 4 17 17 9 2 1 5 14 1 18 12 18 14 18 10 14 14 19 8 1 8 14 14 13 19 9 4 11 13 16 15 13 17 10 16 15 8 10 13 12 19 20 4 6 3 12 3 9 11 15 18 12 2 5 5 14 14 4 12 15 6 14 12 1 8 1 8 14 8 11 13 12 15 17 14 15 7 18 5...
result:
ok ac (100 test cases)
Test #2:
score: 0
Accepted
time: 6962ms
memory: 42536kb
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 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 ...
result:
ok ac (5 test cases)
Test #3:
score: 0
Accepted
time: 4941ms
memory: 42532kb
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: 5782ms
memory: 42700kb
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 2 3 4 5 6 7 8 6 9 10 5 2 6 7 5 2 6 11 10 9 12 8 9 3 3 12 2 10 13 8 7 12 4 3 12 13 13 3 4 5 10 8 6 11 8 13 4 2 4 5 6 7 13 1 8 6 6 8 4 7 3 4 9 8 11 13 10 13 8 5 10 6 8 9 4 10 12 7 12 14 3 4 14 2 1 8 10 7 6 2 10 5 13 9 6 13 6 5 10 11 10 4 8 12 3 6 2 12 12 5 10 14 13 14 4 8 12 13 7 10 10 6 14 4 11 7 4...
result:
ok ac (5 test cases)
Test #5:
score: 0
Accepted
time: 5757ms
memory: 5480kb
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 2 3 4 5 1 6 7 8 9 6 5 10 10 11 12 11 1 3 7 13 1 12 3 14 7 15 9 16 15 9 12 15 16 5 17 18 13 12 5 19 12 8 1 2 3 4 5 6 7 3 4 7 8 9 10 11 1 12 13 7 13 12 2 6 12 14 11 7 1 15 9 4 12 16 13 5 17 14 12 16 11 18 6 14 16 8 4 11 12 19 9 9 7 18 17 13 19 11 19 12 7 5 15 16 14 9 12 3 17 3 14 18 18 4 12 11 1 10 ...
result:
ok ac (98934 test cases)
Test #6:
score: 0
Accepted
time: 2215ms
memory: 42660kb
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: 727ms
memory: 5520kb
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 2 1 1 2 1 2 1 2 2 2 1 2 2 2 2 2 2 1 1 2 2 1 2 2 2 2 2 1 2 2 1 2 2 1 3 1 2 3 2 1 1 2 1 1 2 2 2 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 3 3 2 3 3 3 3 3 2 3 3 3 3 1 1 1 2 2 3 3 3 3 1 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 3 3 3 3 3 1 1 2 2 1 2 1 1 2 2 2 2 1 2 1 1 2 2 1 2 2 ...
result:
ok ac (100000 test cases)
Extra Test:
score: 0
Extra Test Passed