QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#276688 | #7883. Takeout Delivering | supepapupu | WA | 193ms | 34912kb | C++17 | 1.4kb | 2023-12-06 09:31:02 | 2023-12-06 09:31:03 |
Judging History
answer
#include <bits/stdc++.h>
#define x first
#define y second
#define el '\n'
#define debug(x) cout << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int N = 3e5 + 10, INF = 0x3f3f3f3f, mod = 998244353;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int n, m; cin >> n >> m;
vector<vector<pii>> G(n + 1);
priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> e;
int ans = 2e9;
for (int i = 0; i < m; ++i) {
int u, v, w; cin >> u >> v >> w;
G[u].emplace_back(v, w), G[v].emplace_back(u, w);
e.push({w, u, v});
}
vector<int> fa(n + 1);
iota(fa.begin(), fa.end(), 0);
function<int(int)> find = [&](int x) {
return fa[x] == x ? x : fa[x] = find(fa[x]);
};
vector<bool> st(n + 1);
priority_queue<pii, vector<pii>, greater<pii>> Q;
Q.push({0, 1});
while (Q.size()) {
auto[d, u] = Q.top(); Q.pop();
while (e.size() && get<0>(e.top()) < d) {
auto[w, a, b] = e.top(); e.pop();
fa[find(a)] = find(b);
}
if (st[u]) continue;
st[u] = 1;
for (auto[v, k]: G[u]) {
if (find(v) == find(n) && k >= d) ans = min(ans, k + d);
if (!st[v]) Q.push({max(k, d), v});
}
}
cout << ans << el;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3832kb
input:
4 6 1 2 2 1 3 4 1 4 7 2 3 1 2 4 3 3 4 9
output:
5
result:
ok 1 number(s): "5"
Test #2:
score: 0
Accepted
time: 140ms
memory: 26288kb
input:
300000 299999 80516 80517 597830404 110190 110191 82173886 218008 218009 954561262 250110 250111 942489774 66540 66541 156425292 34947 34948 239499776 273789 273790 453201232 84428 84429 439418398 98599 98600 326095035 55636 55637 355015760 158611 158612 684292473 43331 43332 43265001 171621 171622 ...
output:
1999991697
result:
ok 1 number(s): "1999991697"
Test #3:
score: 0
Accepted
time: 193ms
memory: 27716kb
input:
300000 299999 207226 231742 414945003 84591 210444 175968953 46327 51582 612565723 18773 141119 82562646 76139 286963 762958587 131867 224820 928900783 215240 216181 405340417 144725 290878 195350550 267216 268752 846015171 31413 255927 389339642 45219 147512 489502910 113391 215402 555706684 53359 ...
output:
1989898633
result:
ok 1 number(s): "1989898633"
Test #4:
score: 0
Accepted
time: 158ms
memory: 34912kb
input:
300000 299999 1 118488 989720257 1 181002 810258689 1 254222 172925351 1 176703 737330574 1 218306 941887568 1 105741 645573853 1 188490 794789787 1 273997 91455946 1 214929 293300204 1 127289 600097406 1 30589 330284120 1 128954 532459734 1 163729 627033607 1 24073 718818252 1 41571 755054850 1 560...
output:
725564985
result:
ok 1 number(s): "725564985"
Test #5:
score: -100
Wrong Answer
time: 154ms
memory: 31308kb
input:
300000 299999 19784 19785 438457172 153297 239456 192671538 153297 202254 645947104 9640 9641 583410541 153297 221084 490232940 32210 32211 838809517 153297 171896 625627853 153297 216946 683286844 110843 110844 690710575 153297 176413 983037656 74908 74909 375017711 67676 67677 695121437 153297 196...
output:
2000000000
result:
wrong answer 1st numbers differ - expected: '1999992880', found: '2000000000'