QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#273174 | #7883. Takeout Delivering | ucup-team093# | WA | 117ms | 29636kb | C++20 | 1.2kb | 2023-12-02 21:50:17 | 2023-12-02 21:50:17 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using pii = pair<int, int>;
using edge = tuple<int, int, int>;
const int N = 3e5 + 10;
int n, m, dis[2][N];
vector<pii> g[N];
vector<edge> e;
void dij(int *d, int st) {
d[st] = 0;
priority_queue<pii, vector<pii>, greater<pii> > q;
q.push({0, st});
while(q.size()) {
auto [x, u] = q.top();
q.pop();
if(x > d[u]) continue;
for(auto &[v, w] : g[u])
if(max(x, w) < d[v]) {
d[v] = max(x, w);
q.push({d[v], v});
}
}
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> m;
for(int i = 1, u, v, w; i <= m; i ++) {
cin >> u >> v >> w;
e.emplace_back(u, v, w);
g[u].emplace_back(v, w);
g[v].emplace_back(u, w);
}
memset(dis, 0x7f, sizeof dis);
dij(dis[0], 1);
dij(dis[1], n);
int ans = INT_MAX;
for(auto &[u, v, w] : e) {
if(min(dis[0][u], dis[1][v]) <= w) ans = min(ans, w + max(dis[0][u], dis[1][v]));
if(min(dis[0][v], dis[1][u]) <= w) ans = min(ans, w + max(dis[0][v], dis[1][u]));
}
cout << ans;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 13032kb
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: -100
Wrong Answer
time: 117ms
memory: 29636kb
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:
1356916107
result:
wrong answer 1st numbers differ - expected: '1999991697', found: '1356916107'