結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー tailstails
提出日時 2016-12-18 00:28:09
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 349 ms / 2,000 ms
コード長 702 bytes
コンパイル時間 1,461 ms
コンパイル使用メモリ 166,592 KB
実行使用メモリ 34,080 KB
最終ジャッジ日時 2023-08-20 22:09:18
合計ジャッジ時間 6,991 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
12,416 KB
testcase_01 AC 5 ms
12,460 KB
testcase_02 AC 4 ms
12,348 KB
testcase_03 AC 5 ms
12,476 KB
testcase_04 AC 5 ms
12,440 KB
testcase_05 AC 5 ms
12,624 KB
testcase_06 AC 5 ms
12,424 KB
testcase_07 AC 5 ms
12,572 KB
testcase_08 AC 5 ms
12,304 KB
testcase_09 AC 5 ms
12,616 KB
testcase_10 AC 5 ms
12,308 KB
testcase_11 AC 5 ms
12,432 KB
testcase_12 AC 5 ms
12,308 KB
testcase_13 AC 5 ms
12,336 KB
testcase_14 AC 8 ms
12,516 KB
testcase_15 AC 7 ms
12,620 KB
testcase_16 AC 7 ms
12,492 KB
testcase_17 AC 7 ms
12,548 KB
testcase_18 AC 7 ms
12,760 KB
testcase_19 AC 7 ms
12,548 KB
testcase_20 AC 7 ms
12,548 KB
testcase_21 AC 7 ms
12,552 KB
testcase_22 AC 7 ms
12,488 KB
testcase_23 AC 7 ms
12,664 KB
testcase_24 AC 343 ms
34,012 KB
testcase_25 AC 345 ms
34,080 KB
testcase_26 AC 344 ms
33,880 KB
testcase_27 AC 344 ms
34,076 KB
testcase_28 AC 342 ms
33,800 KB
testcase_29 AC 342 ms
33,860 KB
testcase_30 AC 343 ms
33,832 KB
testcase_31 AC 342 ms
33,964 KB
testcase_32 AC 349 ms
33,876 KB
testcase_33 AC 343 ms
33,828 KB
testcase_34 AC 96 ms
23,032 KB
testcase_35 AC 6 ms
12,448 KB
testcase_36 AC 5 ms
12,436 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:35:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   35 | main(){
      | ^~~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int a[500010],b[500010],c[500010];
int n,m;
list<int> xa[100010];
list<int> xb[100010];
int db[100010];
int ta[100010];
int u[100010];
int y;

void f(int a,int t){
//cout << "(a,t)=("<<a<<","<<t<<")"<<endl;
	if(ta[a]<t){
		ta[a]=t;
	}
	if(--db[a]==0){
		for(auto i:xa[a]){
			f(b[i],ta[a]+c[i]);
		}
	}
}

void g(int b,int t){
	if(u[b]++) return;
	--y;
	for(auto i:xb[b]){
		if(ta[a[i]]==t-c[i]){
			g(a[i],t-c[i]);
		}
	}
}

main(){
	cin>>n>>m;
	for(int i=0;i<m;++i){
		cin>>a[i]>>b[i]>>c[i];
		xa[a[i]].push_back(i);
		xb[b[i]].push_back(i);
		++db[b[i]];
	}
	db[0]=1;
	f(0,0);
	y=n;
	g(n-1,ta[n-1]);
	cout << ta[n-1] << " " << y << "/" << n << endl;
}
0