結果
| 問題 |
No.1344 Typical Shortest Path Sum
|
| コンテスト | |
| ユーザー |
Kude
|
| 提出日時 | 2021-01-16 16:24:42 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 1,120 bytes |
| コンパイル時間 | 2,226 ms |
| コンパイル使用メモリ | 196,780 KB |
| 最終ジャッジ日時 | 2025-01-17 23:37:01 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 77 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
template<class T> void chmax(T& a, const T& b) {a = max(a, b);}
template<class T> void chmin(T& a, const T& b) {a = min(a, b);}
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
constexpr ll INF = 1002003004005006007;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
VVL dist(n, VL(n, INF));
rep(i, n) dist[i][i] = 0;
rep(_, m) {
int s, t;
ll d;
cin >> s >> t >> d;
--s, --t;
chmin(dist[s][t], d);
}
rep(k, n) rep(i, n) rep(j, n) {
if (dist[i][k] != INF && dist[k][j] != INF) chmin(dist[i][j], dist[i][k] + dist[k][j]);
}
rep(i, n) rep(j, n) if (dist[i][j] == INF) dist[i][j] = 0;
rep(i, n) {
ll s = 0;
rep(j, n) s += dist[i][j];
cout << s << '\n';
}
}
Kude