結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
ttttan
|
| 提出日時 | 2019-03-31 01:21:54 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,073 bytes |
| コンパイル時間 | 1,900 ms |
| コンパイル使用メモリ | 176,364 KB |
| 実行使用メモリ | 23,000 KB |
| 最終ジャッジ日時 | 2024-11-17 15:54:18 |
| 合計ジャッジ時間 | 8,741 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 12 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef tuple<ll,ll,ll> tl;
ll inf=1000000000000000000;
struct edge{ll len,ma,num;};
bool cmp(edge a,edge b){
if(a.len!=b.len)return a.len<b.len;
else{
if(a.ma!=b.ma)return a.ma<b.ma;
else{
if(a.num!=b.num)return a.num<b.num;
return true;
}
}
}
int main(){
ll n,m;cin>>n>>m;
vector<pll> v[n+1];
for(ll i=0;i<m;i++){
ll a,b,c;cin>>a>>b>>c;
v[a].push_back(make_pair(b,c));
v[b].push_back(make_pair(a,c));
}
ll d[n+1],da[n+1];
fill(d,d+n+1,inf);
fill(da,da+n+1,inf);
priority_queue<pll,vector<pll>,greater<pll>> q;
q.push(make_pair(0,1));
bool used[n+1];
fill(used,used+n+1,false);
d[1]=0;
while(q.size()>0){
pll p=q.top();q.pop();
ll pf=p.first,ps=p.second;
if(used[ps])continue;
used[ps]=true;
for(ll i=0;i<v[ps].size();i++){
ll now=v[ps][i].first;
ll dis=v[ps][i].second;
if(used[now])continue;
if(d[now]>dis+pf){
d[now]=dis+pf;
q.push(make_pair(dis+pf,now));
}
}
}
fill(used,used+n+1,false);
priority_queue<tl,vector<tl>,greater<tl>> qq;
qq.push(make_tuple(0,0,1));
da[1]=0;
while(qq.size()>0){
tl t=qq.top();qq.pop();
ll tf=get<0>(t),ts=get<1>(t),tt=get<2>(t);
if(used[tt])continue;
used[tt]=true;
//cout<<tf<<" "<<ts<<" "<<tt<<endl;
for(int i=0;i<v[tt].size();i++){
ll now=v[tt][i].first;
ll dis=v[tt][i].second;
ll u=dis+tf;
ll y=ts;
if(used[now])continue;
if(ts<dis){
u-=dis-ts;
y=dis;
}
if(da[now]>u){
da[now]=u;
qq.push(make_tuple(u,y,now));
}
}
}
for(ll i=1;i<=n;i++)cout<<d[i]+da[i]<<endl;
for(ll i=1;i<=n;i++){
//cout<<d[i]<<" "<<da[i]<<endl;
}
}
ttttan