#include #if __has_include() #include #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; constexpr int inf = 2e18; struct edge{int to,cost;}; bool chmin(int &a,const int b) { if(a>b) { a=b; return true; } return false; } int n,m; std::vector G[110]; std::vector dijkstra(int s) { std::vector dist(n); std::fill(all(dist),inf); dist[s]=0; std::priority_queue,std::greater

> pri; pri.push({0,s}); while(!pri.empty()) { P p = pri.top();pri.pop(); int v = p.second; if(dist[v]> n >> m; rep(i, m) { int s,t,d; std::cin >> s >> t >> d; s--,t--; // G[s].push_back({t,d}); chmin(dist[s][t],d); } rep(i, n) rep(j, n) if(i!=j&&dist[i][j]!=inf) G[i].push_back({j,dist[i][j]}); rep(i, n) { int sum = 0; std::vector v = dijkstra(i); for(auto &p:v) if(p!=inf) sum+=p; // rep(j, n) sum+=dijkstra(i,j); std::cout << sum << std::endl; } return 0; }