QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#781238 | #7883. Takeout Delivering | pcc1 | Compile Error | / | / | C++14 | 1.8kb | 2024-11-25 15:22:42 | 2024-11-25 15:22:44 |
Judging History
This is the latest submission verdict.
- [2024-11-25 15:22:44]
- Judged
- Verdict: Compile Error
- Time: 0ms
- Memory: 0kb
- [2024-11-25 15:22:42]
- Submitted
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define int long long
using namespace std;
const int N=1e6+10;
int n,m;
struct node{
int to,nxt,w;
}e[N*2];
int head[N],tot;
void add(int a,int b,int c){
e[++tot].nxt=head[a];
head[a]=tot;
e[tot].to=b;
e[tot].w=c;
}
int ans[N];
struct Node{
int id;
int ans1,ans2;
bool operator <(const Node &p)const{
return p.ans1+p.ans2<ans1+ans2;
}
};
int vis[N];
priority_queue<Node>q;
void dij(){
for(int i=1;i<=n;i++){
ans[i]=LONG_LONG_MAX;vis[i]=0;
}
ans[1]=0;
q.push({1,0,0});
while(!q.empty()){
Node t=q.top();q.pop();
int u=t.id;
if(vis[u])continue;
vis[u]=1;
for(int i=head[u];i;i=e[i].nxt){
int v=e[i].to;
if(vis[v])continue;
int anss1=-1,anss2=-1;
if(e[i].w>t.ans1){
anss2=t.ans1;
anss1=e[i].w;
}
else if(e[i].w>t.ans2){
anss1=t.ans1;
anss2=e[i].w;
}
if(anss1==-1)anss1=t.ans1;
if(anss2==-1)anss2=t.ans2;
if(anss1+anss2<ans[v]){
ans[v]=anss1+anss2;
// cout<<v<<" "<<anss1<<"-="<<anss2<<"\n";
if(!vis[v]){
q.push({v,anss1,anss2});
}
}
}
}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>n>>m;
int u,v,w;
int ww=1e9+10;
for(int i=1;i<=m;i++){
cin>>u>>v>>w;
if(u==1&&v==n)ww=min(ww,w);
if(u==n&&v==1)ww=min(ww,w);
add(u,v,w);
add(v,u,w);
}
dij();
cout<<min(ans[n],ww);
return 0;
}
Details
answer.code: In function ‘void dij()’: answer.code:32:16: error: ‘LONG_LONG_MAX’ was not declared in this scope 32 | ans[i]=LONG_LONG_MAX;vis[i]=0; | ^~~~~~~~~~~~~