結果

問題 No.1344 Typical Shortest Path Sum
ユーザー tada721
提出日時 2021-01-16 14:11:12
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 1,309 bytes
コンパイル時間 859 ms
コンパイル使用メモリ 86,472 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2024-11-27 15:18:09
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 25 WA * 48 RE * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
#include<queue>
#include<math.h>
#include<deque>
#include<set>
#include<bitset>
using namespace std;
#define double long double
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define dc(d) double d;cin>>d;
#define mod 100000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define pi 3.141592653589793238462643383279
#define e_ 2.718281828459045235360287471352
#define P pair<int,int>
#define upp(a,n,x) upper_bound(a,a+n,x)-a;
#define low(a,n,x) lower_bound(a,a+n,x)-a;
#define pb push_back
struct edge{
	int from;
	int to;
	int cost;
};
int a[114],b[114],c[114];
int d[114];
signed main(){
	ic(n) ic(m)
	vector<edge> e;
	rep(0,i,m){
		struct edge add;
		cin>>a[i]>>b[i]>>c[i];
		add.from=a[i]-1;
		add.to=b[i]-1;
		add.cost=c[i];
		e.pb(add);
	}
	rep(0,p,n){
		rep(0,i,n)d[i]=inf;
		d[p]=0;
		rep(0,i,n){
			rep(0,j,m){
				struct edge f=e[j];
				if(d[f.to]>d[f.from]+f.cost){
					d[f.to]=d[f.from]+f.cost;
				}	
			}	
		}
		int sum=0;
		rep(0,i,n){
			if(d[i]!=inf)sum+=d[i];
		}
		c(sum)
	}
}
0