QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#875579 | #2746. Highway Tolls | Wansur | 6 | 45ms | 19764kb | C++20 | 2.5kb | 2025-01-29 23:30:07 | 2025-01-29 23:30:08 |
Judging History
answer
#include "highway.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 2e5 + 12;
vector<pair<int, int>> g[maxn];
ll d1[maxn], d2[maxn];
ll a, b;
int n, m;
vector<array<int, 3>> bfs(int v, ll d[]) {
vector<array<int, 3>> res;
for(int i = 0; i < n; i++) {
if(d[i] >= 0) {
d[i] = 1e18;
}
}
d[v] = 0;
queue<int> q;
res.push_back({v, v, -1});
q.push(v);
while(q.size()) {
int u = q.front();
q.pop();
for(auto [to, id] : g[u]) {
if(d[to] > d[u] + 1) {
q.push(to);
d[to] = d[u] + 1;
res.push_back({u, to, id});
}
}
}
return res;
}
void find_pair(int N, std::vector<int> U, std::vector<int> V, int A, int B) {
n = N, m = (int)U.size();
a = A, b = B;
for(int i = 0; i < m; i++) {
g[U[i]].push_back({V[i], i});
g[V[i]].push_back({U[i], i});
}
int pos = -1;
ll len = ask(vector<int> (m, 0));
len /= a;
for(int l = 0, r = m - 1; l <= r;) {
int mid = (l + r) >> 1;
vector<int> w(m, 0);
for(int i = 0; i <= mid; i++) {
w[i] = 1;
}
if(ask(w) > len * a) {
pos = mid;
r = mid - 1;
}
else l = mid + 1;
}
vector<int> ww(m, 0);
ww[0] = 1;
bfs(U[pos], d1);
bfs(V[pos], d2);
vector<int> s, t;
for(int i = 0; i < n; i++) {
if(d1[i] < d2[i]) {
s.push_back(i);
d2[i] = -1;
}
if(d2[i] < d1[i]) {
t.push_back(i);
d1[i] = -1;
}
}
auto ord = bfs(U[pos], d1);
auto orz = bfs(V[pos], d2);
int u = -1, v = -1;
for(int l = 0, r = (int)ord.size() - 1; l <= r;) {
int mid = (l + r) >> 1;
vector<int> w(m, 0);
for(int i = 1; i < ord.size(); i++) {
w[ord[i][2]] = (i > mid);
}
if(ask(w) == len * a) {
u = ord[mid][1];
r = mid - 1;
}
else l = mid + 1;
}
for(int l = 0, r = (int)orz.size() - 1; l <= r;) {
int mid = (l + r) >> 1;
vector<int> w(m, 0);
for(int i = 1; i < orz.size(); i++) {
w[orz[i][2]] = (i > mid);
}
if(ask(w) == len * a) {
v = orz[mid][1];
r = mid - 1;
}
else l = mid + 1;
}
answer(u, v);
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3968kb
input:
100 99 1 2 0 75 15 17 47 98 19 41 22 51 38 7 96 5 47 75 28 12 6 0 25 76 0 11 32 66 97 81 23 56 32 94 46 79 18 2 0 3 44 33 89 97 49 31 43 65 56 9 71 93 87 18 12 37 94 34 73 42 66 15 15 8 27 85 3 37 57 28 74 12 69 60 91 24 82 39 60 15 67 78 1 47 19 92 86 75 30 38 86 14 50 96 38 89 50 68 70 52 63 12 12...
output:
Wrong Answer: {s, t} is wrong
result:
wrong answer
Subtask #2:
score: 0
Wrong Answer
Test #13:
score: 7
Accepted
time: 1ms
memory: 3968kb
input:
1000 999 1 3 0 874 571 255 559 871 73 988 563 389 502 605 104 306 874 383 591 152 89 697 365 670 830 695 726 652 271 643 284 50 607 442 30 361 579 346 435 799 972 675 310 421 122 47 222 915 343 917 622 336 888 484 48 11 761 419 305 678 504 115 28 121 133 132 369 296 415 982 408 434 24 132 492 764 94...
output:
Accepted: 22
result:
points 1.0
Test #14:
score: 0
Wrong Answer
time: 4ms
memory: 5680kb
input:
10000 9999 1 3 0 7650 1956 9583 750 9613 4903 611 675 6702 3628 3571 4850 7322 3611 2556 4971 1034 149 4505 728 9017 468 6098 108 5935 2193 6777 1768 8614 7347 961 1341 3402 3645 5743 4379 3376 8128 8157 9926 3111 5351 3204 7818 1909 1405 3238 6580 6390 4042 1739 6798 6558 695 8033 4018 6957 7477 33...
output:
Wrong Answer: {s, t} is wrong
result:
wrong answer
Subtask #3:
score: 6
Accepted
Test #27:
score: 6
Accepted
time: 3ms
memory: 5320kb
input:
10000 9999 1 3 1402 1418 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49 ...
output:
Accepted: 28
result:
points 1.0
Test #28:
score: 6
Accepted
time: 6ms
memory: 7104kb
input:
20002 20001 3 5 3646 7187 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 49...
output:
Accepted: 30
result:
points 1.0
Test #29:
score: 6
Accepted
time: 7ms
memory: 8544kb
input:
30000 29999 3 4 26368 26404 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 ...
output:
Accepted: 28
result:
points 1.0
Test #30:
score: 6
Accepted
time: 35ms
memory: 19632kb
input:
90000 89999 97 116 34441 51220 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 ...
output:
Accepted: 35
result:
points 1.0
Test #31:
score: 6
Accepted
time: 21ms
memory: 19144kb
input:
90000 89999 995 999 33558 33576 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48...
output:
Accepted: 35
result:
points 1.0
Test #32:
score: 6
Accepted
time: 45ms
memory: 19764kb
input:
90000 89999 1 5 18002 75519 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 ...
output:
Accepted: 35
result:
points 1.0
Test #33:
score: 6
Accepted
time: 26ms
memory: 18952kb
input:
90000 89999 1 3 85340 85378 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 ...
output:
Accepted: 31
result:
points 1.0
Test #34:
score: 6
Accepted
time: 41ms
memory: 19632kb
input:
90000 89999 3 7 26589 59072 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 46 47 47 48 48 ...
output:
Accepted: 35
result:
points 1.0
Test #35:
score: 6
Accepted
time: 25ms
memory: 19376kb
input:
90000 89999 50162688 65928896 66873 68839 0 1 1 2 2 3 3 4 4 5 5 6 6 7 7 8 8 9 9 10 10 11 11 12 12 13 13 14 14 15 15 16 16 17 17 18 18 19 19 20 20 21 21 22 22 23 23 24 24 25 25 26 26 27 27 28 28 29 29 30 30 31 31 32 32 33 33 34 34 35 35 36 36 37 37 38 38 39 39 40 40 41 41 42 42 43 43 44 44 45 45 46 4...
output:
Accepted: 32
result:
points 1.0
Subtask #4:
score: 0
Wrong Answer
Test #36:
score: 0
Wrong Answer
time: 0ms
memory: 4096kb
input:
1000 999 1 2 685 383 303 325 476 191 222 120 555 130 655 639 211 393 795 613 389 888 960 815 446 325 846 315 51 348 409 82 470 402 681 258 772 969 767 164 290 46 34 887 453 584 142 73 814 603 36 665 701 727 200 702 638 685 33 580 422 859 550 486 849 250 319 144 189 502 140 63 650 765 251 942 304 99 ...
output:
Wrong Answer: {s, t} is wrong
result:
wrong answer
Subtask #5:
score: 0
Wrong Answer
Test #61:
score: 0
Wrong Answer
time: 11ms
memory: 5568kb
input:
10000 11000 1 2 4410 9396 4021 14 6386 7290 4635 4576 1295 5062 8655 8174 3709 4958 7062 1337 6608 2435 9704 3638 5777 2945 1125 365 2861 1023 1560 8478 1423 7827 2638 6211 1429 4399 626 6111 9981 7033 7740 7631 3904 3628 2812 6221 9946 2671 1646 6255 2653 7666 5575 3080 8314 2317 1868 7058 8177 514...
output:
Wrong Answer: {s, t} is wrong
result:
wrong answer
Subtask #6:
score: 0
Wrong Answer
Test #82:
score: 0
Wrong Answer
time: 7ms
memory: 5732kb
input:
10000 11000 1 3 242 6594 7153 1171 3833 5240 2223 8238 7347 5616 7332 7717 1485 7260 2323 3839 7359 9719 6973 7446 9821 1553 4652 663 3200 30 9465 9801 5461 4480 2298 513 5950 7473 4726 6408 7990 2674 4736 7663 9124 7932 1022 807 6870 6840 8507 62 4036 7781 1867 4826 9093 6486 9303 7974 5399 4503 90...
output:
Wrong Answer: {s, t} is wrong
result:
wrong answer