結果
| 問題 |
No.807 umg tours
|
| コンテスト | |
| ユーザー |
ngtkana
|
| 提出日時 | 2020-03-30 22:21:31 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 1,119 bytes |
| コンパイル時間 | 2,568 ms |
| コンパイル使用メモリ | 206,208 KB |
| 最終ジャッジ日時 | 2025-01-09 11:07:50 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 25 TLE * 1 |
ソースコード
#include<bits/stdc++.h>
using lint=long long;
using real=long double;
int main(){
std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
lint n,m;std::cin>>n>>m;
std::vector<std::vector<std::pair<lint,lint>>>g(2*n);
while(m--){
lint a,b,c;std::cin>>a>>b>>c;a--,b--;
g.at(a).emplace_back(b,c);
g.at(b).emplace_back(a,c);
g.at(a).emplace_back(n+b,0);
g.at(b).emplace_back(n+a,0);
g.at(n+a).emplace_back(n+b,c);
g.at(n+b).emplace_back(n+a,c);
}
lint inf=std::numeric_limits<lint>::max();
std::vector<lint>dist(2*n,inf);
dist.at(0)=0;
std::priority_queue<std::pair<lint,lint>>que;
que.emplace(0,0);
while(!que.empty()){
lint x=que.top().second;que.pop();
for(auto&&[y,w]:g.at(x)){
lint d=dist.at(x)+w;
if(dist.at(y)<=d)continue;
que.emplace(-d,y);
dist.at(y)=d;
}
}
std::cout<<0<<'\n';
for(lint i=1;i<n;i++){
std::cout<<dist.at(i)+dist.at(n+i)<<'\n';
}
}
ngtkana