結果
問題 | No.1344 Typical Shortest Path Sum |
ユーザー |
👑 ![]() |
提出日時 | 2021-01-16 13:08:35 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 544 bytes |
コンパイル時間 | 1,813 ms |
コンパイル使用メモリ | 192,092 KB |
最終ジャッジ日時 | 2025-01-17 21:40:46 |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 WA * 49 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:13:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 13 | scanf("%d%d",&N,&M); | ~~~~~^~~~~~~~~~~~~~ main.cpp:16:33: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 16 | rep(i,M){ int u,v; LL d; scanf("%d%d%lld",&u,&v,&d); u--; v--; D[u][v]=min(D[u][v],d); } | ~~~~~^~~~~~~~~~~~~~~~~~~~~
ソースコード
#include<bits/stdc++.h>using namespace std;using LL=long long;using ULL=unsigned long long;#define rep(i,n) for(int i=0; i<(n); i++)const LL INF=1000000000000000;int N,M;LL D[100][100];int main(){scanf("%d%d",&N,&M);rep(i,N) rep(j,N) D[i][j]=INF;rep(i,N) D[i][i]=0;rep(i,M){ int u,v; LL d; scanf("%d%d%lld",&u,&v,&d); u--; v--; D[u][v]=min(D[u][v],d); }rep(i,N) rep(j,N) rep(k,N) D[j][k]=min(D[j][k],D[j][i]+D[i][k]);rep(i,N){ LL ans=0; rep(j,N) if(D[i][j]!=INF) ans+=D[i][j]; printf("%lld\n",ans); }return 0;}