結果
| 問題 |
No.1344 Typical Shortest Path Sum
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-01-16 13:22:23 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 935 bytes |
| コンパイル時間 | 6,958 ms |
| コンパイル使用メモリ | 229,044 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-27 13:41:41 |
| 合計ジャッジ時間 | 5,639 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 28 WA * 49 |
ソースコード
#include<bits/stdc++.h>
#if __has_include(<atcoder/all>)
#include<atcoder/all>
#endif
// using namespace std;
// using namespace atcoder;
#define int long long
#define rep(i, n) for(int i = 0;i<(int)(n);i++)
#define all(v) (v).begin(),(v).end()
using lint = long long;
using ll = long long;
using P = std::pair<int,int>;
constexpr int inf = 2e18;
bool chmin(int &a,const int b) {
if(a>b) {
a=b;
return true;
}
return false;
}
int dist[110][110];
signed main(void) {
rep(i, 110) rep(j, 110) if(i!=j) dist[i][j]=inf;
int n,m;
std::cin >> n >> m;
rep(i, m) {
int s,t,d;
std::cin >> s >> t >> d;
s--,t--;
chmin(dist[s][t],d);
}
rep(k, n) rep(i, n) rep(j, n) chmin(dist[i][j],dist[i][k]+dist[k][j]);
rep(i, n) {
int sum = 0;
rep(j, n) if(dist[i][j]!=inf) sum+=dist[i][j];
std::cout << sum << std::endl;
}
return 0;
}