結果
問題 |
No.1344 Typical Shortest Path Sum
|
ユーザー |
|
提出日時 | 2021-01-16 20:43:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 541 bytes |
コンパイル時間 | 503 ms |
コンパイル使用メモリ | 67,584 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-28 02:49:01 |
合計ジャッジ時間 | 2,505 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 77 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<algorithm> using namespace std; int N,M; long D[100][100]; main() { cin>>N>>M; for(int i=0;i<N;i++)for(int j=0;j<N;j++)if(i!=j)D[i][j]=1e18; for(int i=0;i<M;i++) { int s,t;long d; cin>>s>>t>>d; s--,t--; if(D[s][t]>d)D[s][t]=d; } for(int k=0;k<N;k++)for(int i=0;i<N;i++)for(int j=0;j<N;j++) { if(D[i][k]<(long)1e18&&D[k][j]<(long)1e18)D[i][j]=min(D[i][j],D[i][k]+D[k][j]); } for(int i=0;i<N;i++) { long now=0; for(int j=0;j<N;j++)if(D[i][j]<(long)1e18)now+=D[i][j]; cout<<now<<endl; } }