結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー hirokazu1020hirokazu1020
提出日時 2016-12-18 00:15:44
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,649 bytes
コンパイル時間 1,137 ms
コンパイル使用メモリ 103,900 KB
実行使用メモリ 9,032 KB
最終ジャッジ日時 2024-05-08 04:19:43
合計ジャッジ時間 4,799 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _CRT_SECURE_NO_WARNINGS
#include<sstream>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



vector<int> topologicalSort(int v, const vector<int> edge[]) {
	vector<int> zeros;
	vector<int> in(v), res;
	for (int i = 0; i<v; i++) {
		for (int j = 0; j<(int)edge[i].size(); j++)in[edge[i][j]]++;
	}
	for (int i = 0; i<v; i++)if (in[i] == 0)zeros.push_back(i);
	while (!zeros.empty()) {
		int u = zeros.back();
		zeros.pop_back();
		res.push_back(u);
		for (int i = 0; i<(int)edge[u].size(); i++) {
			if (--in[edge[u][i]] == 0)zeros.push_back(edge[u][i]);
		}
	}
	return res;
}





int n, m;
vector<int> e[50000];
vector<pair<int, int>> edge[50000];
 
int dp[50000];

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> n >> m;
	rep(i,m) {
		int a, b, c;
		cin >> a >> b >> c;
		e[a].push_back(b);
		edge[a].emplace_back(b, c);
	}
	auto ord = topologicalSort(n, e);
	rep(i,n) {
		for (auto p : edge[ord[i]]) {
			dp[p.first] = max(dp[p.first], dp[ord[i]] + p.second);
		}
	}
	int cnt = 1;
	rep(i, n) {
		bool f = true;
		for (auto p : edge[ord[i]]) {
			if (dp[p.first] == dp[ord[i]] + p.second)f = false;
		}
		if (f)cnt++;
	}

	cout << dp[n - 1] << ' ' << cnt << '/' << n << endl;

	
	return 0;
}
0