QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#682949 | #7883. Takeout Delivering | downfall | WA | 159ms | 46456kb | C++17 | 1.6kb | 2024-10-27 18:05:33 | 2024-10-27 18:05:34 |
Judging History
answer
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define rep(i, l, r) for (int i = l; i <= r; i++)
#define frep(i, l, r) for (int i = l; i >= r; i--)
#define eb emplace_back
#define pb push_back
#define endl "\n"
// #define int long long
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int N = 1e6 + 3;
const int inf = 0x3f3f3f3f;
int n, m;
vector<PII> ve[N];
vector<int> dijkstra(int root)
{
vector<int> d(n + 3, inf), vis(n + 3, 0);
d[root] = 0;
priority_queue<PII, vector<PII>, greater<PII>> qu;
qu.push({d[root], root});
while (!qu.empty())
{
int t = qu.top().second;
qu.pop();
if (vis[t])
continue;
vis[t] = true;
for (auto k : ve[t])
{
int u = k.first, v = k.second;
if (d[v] > max(d[t], u))
{
d[v] = max(d[t], u);
qu.push({d[v], v});
}
}
}
return d;
}
struct node
{
int u, v, w;
} a[N];
void solve()
{
cin >> n >> m;
rep(i, 1, m)
{
int u, v, w;
cin >> u >> v >> w;
ve[u].pb({w, v});
ve[v].pb({w, u});
a[i] = node{u, v, w};
}
auto d1 = dijkstra(1), d2 = dijkstra(n);
int res = 2e9;
rep(i, 1, m)
{
int u = a[i].u, v = a[i].v, w = a[i].w;
if (max(d1[u], d2[v]) <= w)
res = min(res, w + max(d1[u], d2[v]));
}
cout << res << endl;
}
signed main()
{
IOS;
int T = 1;
// cin >> T;
while (T--)
solve();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 27268kb
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: 113ms
memory: 45024kb
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: -100
Wrong Answer
time: 159ms
memory: 46456kb
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:
1993277688
result:
wrong answer 1st numbers differ - expected: '1989898633', found: '1993277688'