QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#781258 | #7883. Takeout Delivering | wangyongkai | WA | 3ms | 32156kb | C++14 | 1.4kb | 2024-11-25 15:26:20 | 2024-11-25 15:26:22 |
Judging History
answer
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<stack>
#include<queue>
#include<map>
#include<vector>
#include<cstdio>
#include<set>
#include<bitset>
#include<iomanip>
#define int long long
using namespace std;
int n,m;
const int N=1e6+5;
const int inf=1145141919810;
struct node{
int v,w;
};
vector<node>e[N];
int maxn[N],maxn1[N],vis[N];
int ans=inf;
inline void dij(int s)
{
queue<int>q;
for(int i=1;i<=n;i++) vis[i]=0,maxn[i]=0,maxn1[i]=0;
q.push(s);
while(!q.empty())
{
int u=q.front();
q.pop();
if(vis[u]) continue;
vis[u]=1;
for(auto i:e[u])
{
int v=i.v,w=i.w;
if(w>maxn[u])
{
maxn[v]=w;
maxn1[v]=maxn[u];
}
else if(w==maxn[u])
{
maxn[v]=maxn[u];
maxn1[v]=maxn[u];
}
else if(w<maxn[u])
{
if(w>=maxn1[u])
{
maxn[v]=maxn[u];
maxn1[v]=w;
}
else
{
maxn[v]=maxn[u];
maxn1[v]=maxn1[u];
}
}
if(v==n)
{
ans=min(ans,maxn[n]+maxn1[n]);
cout<<maxn[v]<<' '<<maxn1[v]<<'\n';
}
q.push(v);
}
}
}
signed main()
{
// freopen("takeout2.in","r",stdin);
// freopen(".out","w",stdout);
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin>>n>>m;
for(int i=1;i<=m;i++)
{
int u,v,w;
cin>>u>>v>>w;
e[u].push_back({v,w});
e[v].push_back({u,w});
}
dij(1);
cout<<ans;
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 3ms
memory: 32156kb
input:
4 6 1 2 2 1 3 4 1 4 7 2 3 1 2 4 3 3 4 9
output:
7 0 3 2 9 2 5
result:
wrong answer 1st numbers differ - expected: '5', found: '7'