結果

問題 No.1607 Kth Maximum Card
ユーザー kotatsugamekotatsugame
提出日時 2021-07-16 21:49:24
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 944 ms / 3,500 ms
コード長 882 bytes
コンパイル時間 822 ms
コンパイル使用メモリ 79,676 KB
実行使用メモリ 17,620 KB
最終ジャッジ日時 2023-09-20 13:35:40
合計ジャッジ時間 10,542 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,500 KB
testcase_01 AC 4 ms
9,560 KB
testcase_02 AC 4 ms
9,520 KB
testcase_03 AC 4 ms
9,524 KB
testcase_04 AC 4 ms
9,576 KB
testcase_05 AC 5 ms
9,512 KB
testcase_06 AC 5 ms
9,512 KB
testcase_07 AC 5 ms
9,716 KB
testcase_08 AC 656 ms
17,620 KB
testcase_09 AC 445 ms
16,388 KB
testcase_10 AC 645 ms
17,612 KB
testcase_11 AC 76 ms
11,444 KB
testcase_12 AC 421 ms
15,840 KB
testcase_13 AC 57 ms
10,668 KB
testcase_14 AC 70 ms
11,332 KB
testcase_15 AC 372 ms
15,644 KB
testcase_16 AC 59 ms
10,876 KB
testcase_17 AC 23 ms
10,040 KB
testcase_18 AC 209 ms
13,740 KB
testcase_19 AC 126 ms
12,252 KB
testcase_20 AC 185 ms
12,848 KB
testcase_21 AC 200 ms
13,396 KB
testcase_22 AC 692 ms
16,536 KB
testcase_23 AC 688 ms
16,604 KB
testcase_24 AC 146 ms
11,772 KB
testcase_25 AC 85 ms
10,952 KB
testcase_26 AC 102 ms
11,356 KB
testcase_27 AC 159 ms
11,984 KB
testcase_28 AC 132 ms
11,432 KB
testcase_29 AC 302 ms
13,732 KB
testcase_30 AC 944 ms
16,532 KB
testcase_31 AC 301 ms
13,300 KB
testcase_32 AC 156 ms
14,876 KB
testcase_33 AC 156 ms
14,936 KB
testcase_34 AC 156 ms
14,956 KB
testcase_35 AC 156 ms
15,036 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:43:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   43 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<deque>
using namespace std;
int N,M,K;
vector<pair<int,int> >G[2<<17];
bool check(int L)
{
	vector<int>dist(N,1e9);
	vector<bool>vis(N,false);
	dist[0]=0;
	deque<int>P;
	P.push_back(0);
	while(!P.empty())
	{
		int u=P.front();
		P.pop_front();
		if(vis[u])continue;
		vis[u]=true;
		for(pair<int,int>e:G[u])
		{
			int v=e.first;
			if(e.second>L)
			{
				if(dist[v]>dist[u]+1)
				{
					dist[v]=dist[u]+1;
					P.push_back(v);
				}
			}
			else
			{
				if(dist[v]>dist[u])
				{
					dist[v]=dist[u];
					P.push_front(v);
				}
			}
		}
	}
	return dist[N-1]<K;
}
main()
{
	cin>>N>>M>>K;
	for(int i=0;i<M;i++)
	{
		int u,v,c;cin>>u>>v>>c;
		u--,v--;
		G[u].push_back(make_pair(v,c));
		G[v].push_back(make_pair(u,c));
	}
	int L=-1,R=2e5;
	while(R-L>1)
	{
		int mid=(L+R)/2;
		if(check(mid))R=mid;
		else L=mid;
	}
	cout<<R<<endl;
}
0