結果

問題 No.468 役に立つ競技プログラミング実践編
ユーザー kotatsugamekotatsugame
提出日時 2019-11-20 01:53:47
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 298 ms / 2,000 ms
コード長 925 bytes
コンパイル時間 781 ms
コンパイル使用メモリ 81,464 KB
実行使用メモリ 20,992 KB
最終ジャッジ日時 2024-04-15 06:05:27
合計ジャッジ時間 6,050 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
10,052 KB
testcase_01 AC 3 ms
10,260 KB
testcase_02 AC 3 ms
9,832 KB
testcase_03 AC 4 ms
10,496 KB
testcase_04 AC 3 ms
10,588 KB
testcase_05 AC 4 ms
11,328 KB
testcase_06 AC 4 ms
10,628 KB
testcase_07 AC 4 ms
10,980 KB
testcase_08 AC 3 ms
10,304 KB
testcase_09 AC 5 ms
11,400 KB
testcase_10 AC 5 ms
11,164 KB
testcase_11 AC 4 ms
10,024 KB
testcase_12 AC 5 ms
11,724 KB
testcase_13 AC 4 ms
10,148 KB
testcase_14 AC 6 ms
10,244 KB
testcase_15 AC 7 ms
11,432 KB
testcase_16 AC 6 ms
11,112 KB
testcase_17 AC 6 ms
10,288 KB
testcase_18 AC 6 ms
10,876 KB
testcase_19 AC 6 ms
11,460 KB
testcase_20 AC 6 ms
10,120 KB
testcase_21 AC 7 ms
10,820 KB
testcase_22 AC 6 ms
10,404 KB
testcase_23 AC 6 ms
10,236 KB
testcase_24 AC 296 ms
20,904 KB
testcase_25 AC 288 ms
20,632 KB
testcase_26 AC 290 ms
20,764 KB
testcase_27 AC 294 ms
20,952 KB
testcase_28 AC 292 ms
20,604 KB
testcase_29 AC 290 ms
20,992 KB
testcase_30 AC 298 ms
20,624 KB
testcase_31 AC 292 ms
20,884 KB
testcase_32 AC 288 ms
20,840 KB
testcase_33 AC 291 ms
20,784 KB
testcase_34 AC 91 ms
17,876 KB
testcase_35 AC 5 ms
11,068 KB
testcase_36 AC 4 ms
10,344 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int N,M;
vector<pair<int,int> >G[1<<17],rG[1<<17];
int cnt[1<<17],rcnt[1<<17];
int d[1<<17],rd[1<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int a,b,c;cin>>a>>b>>c;
		G[a].push_back(make_pair(b,c));
		rG[b].push_back(make_pair(a,c));
		cnt[b]++;
		rcnt[a]++;
	}
	for(int i=0;i<N;i++)rd[i]=1e9;
	queue<int>P;
	P.push(0);
	while(!P.empty())
	{
		int u=P.front();P.pop();
		for(pair<int,int>p:G[u])
		{
			int v=p.first;
			int c=p.second+d[u];
			if(d[v]<c)d[v]=c;
			cnt[v]--;
			if(cnt[v]==0)P.push(v);
		}
	}
	rd[N-1]=d[N-1];
	P.push(N-1);
	while(!P.empty())
	{
		int u=P.front();P.pop();
		for(pair<int,int>p:rG[u])
		{
			int v=p.first;
			int c=rd[u]-p.second;
			if(rd[v]>c)rd[v]=c;
			rcnt[v]--;
			if(rcnt[v]==0)P.push(v);
		}
	}
	int C=0;
	for(int i=0;i<N;i++)C+=d[i]<rd[i];
	cout<<d[N-1]<<" "<<C<<"/"<<N<<endl;
}
0