結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー srup٩(๑`н´๑)۶srup٩(๑`н´๑)۶
提出日時 2016-12-20 18:37:50
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 1,421 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 147,224 KB
実行使用メモリ 14,468 KB
最終ジャッジ日時 2023-08-21 03:21:45
合計ジャッジ時間 6,356 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,824 KB
testcase_01 AC 3 ms
5,852 KB
testcase_02 AC 3 ms
5,932 KB
testcase_03 AC 4 ms
5,820 KB
testcase_04 AC 3 ms
5,852 KB
testcase_05 AC 3 ms
5,880 KB
testcase_06 AC 4 ms
5,832 KB
testcase_07 AC 3 ms
5,824 KB
testcase_08 AC 3 ms
5,844 KB
testcase_09 AC 4 ms
5,828 KB
testcase_10 AC 4 ms
5,884 KB
testcase_11 AC 3 ms
5,932 KB
testcase_12 AC 4 ms
5,824 KB
testcase_13 AC 4 ms
5,884 KB
testcase_14 AC 6 ms
5,880 KB
testcase_15 AC 6 ms
5,864 KB
testcase_16 AC 5 ms
6,128 KB
testcase_17 AC 5 ms
5,868 KB
testcase_18 AC 6 ms
6,136 KB
testcase_19 AC 6 ms
5,860 KB
testcase_20 AC 5 ms
6,124 KB
testcase_21 AC 5 ms
5,864 KB
testcase_22 AC 5 ms
5,868 KB
testcase_23 AC 5 ms
5,924 KB
testcase_24 AC 252 ms
11,944 KB
testcase_25 AC 254 ms
11,784 KB
testcase_26 AC 252 ms
11,992 KB
testcase_27 AC 252 ms
11,760 KB
testcase_28 AC 253 ms
11,772 KB
testcase_29 AC 253 ms
11,812 KB
testcase_30 AC 254 ms
11,768 KB
testcase_31 AC 252 ms
11,768 KB
testcase_32 AC 254 ms
11,760 KB
testcase_33 AC 250 ms
11,768 KB
testcase_34 AC 87 ms
14,468 KB
testcase_35 AC 4 ms
5,872 KB
testcase_36 AC 3 ms
5,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int n, m;
vector<pair<int, int> > dist[100010];
int cost[100010];
bool used[100010], check[100010];

void max_dfs(int u){//赤色の数字を求める
	if(used[u]) return;
    if(!used[u]){
    	used[u] = true;
  		for(auto v : dist[u]){ // u -> v
  			max_dfs(v.fi);
  			//ゴールから戻す
  			chmax(cost[u], cost[v.fi] + v.se);
  		}
    }
}

void kuriteical_dfs(int u){//赤色の線
    if(check[u]) return;
    if(!check[u]){
    	check[u] = true;
  		for(auto v : dist[u]){ // u -> v
  			if(cost[u] == cost[v.fi] + v.se){//ぎりぎり
  				kuriteical_dfs(v.fi);
  			}
  		}
    }
}
int main(void){
	cin >> n >> m;
	rep(i, m){
		int a, b, c; cin >> a >> b >> c;
		dist[a].pb(mp(b, c));//a -> b
	}
	max_dfs(0);
	kuriteical_dfs(0);
	int ans = n;
	rep(i, n){
		if(check[i]) ans--;
	}
	printf("%d %d/%d\n", cost[0], ans, n);
	return 0;
}
0