QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#633937 | #7883. Takeout Delivering | Star_s | WA | 255ms | 20276kb | C++14 | 1.1kb | 2024-10-12 16:27:01 | 2024-10-12 16:27:01 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int MAX = 3e5 + 9;
struct edge{
int u, v, w;
};
struct node{
int u, w1, w2;
friend bool operator < (node a, node b)
{
return a.w1 + a.w2 > b.w1 + b.w2;
}
};
int n, m;
bool vis[MAX];
vector<edge> g[MAX];
priority_queue<node> q;
void dijk()
{
q.push({1, 0, 0});
int flag = 1e9 + 7;
while (!q.empty())
{
int u = q.top().u;
int w1 = q.top().w1;
int w2 = q.top().w2;
// cout << u << " " << w1 << " " << w2 << "\n";
if (u == n)
{
flag = min(flag, w1 + w2);
}
q.pop();
if (vis[u]) continue;
vis[u] = 1;
for (int k = 0; k < g[u].size(); k++)
{
node nnn;
int v = g[u][k].v;
int w = g[u][k].w;
if (w <= min(w1, w2))
{
nnn.u = v;
nnn.w1 = w1;
nnn.w2 = w2;
}
else
{
nnn.u = v;
nnn.w1 = max(w1, w2);
nnn.w2 = w;
}
q.push(nnn);
}
}
cout << flag << "\n";
}
int main()
{
cin >> n >> m;
for (int i = 1; i <= m; i++)
{
int u, v, w;
cin >> u >> v >> w;
g[u].push_back({u, v, w});
g[v].push_back({v, u, w});
}
dijk();
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 10752kb
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: 255ms
memory: 20276kb
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:
1000000007
result:
wrong answer 1st numbers differ - expected: '1999991697', found: '1000000007'