結果

問題 No.1480 Many Complete Graphs
ユーザー kotatsugamekotatsugame
提出日時 2021-04-24 05:51:43
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 111 ms / 2,000 ms
コード長 889 bytes
コンパイル時間 672 ms
コンパイル使用メモリ 79,120 KB
実行使用メモリ 19,964 KB
最終ジャッジ日時 2023-09-17 13:28:50
合計ジャッジ時間 5,786 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
13,584 KB
testcase_01 AC 5 ms
13,796 KB
testcase_02 AC 4 ms
13,592 KB
testcase_03 AC 4 ms
13,576 KB
testcase_04 AC 5 ms
13,592 KB
testcase_05 AC 5 ms
13,724 KB
testcase_06 AC 5 ms
13,592 KB
testcase_07 AC 5 ms
13,652 KB
testcase_08 AC 5 ms
13,584 KB
testcase_09 AC 5 ms
13,644 KB
testcase_10 AC 5 ms
13,872 KB
testcase_11 AC 5 ms
13,608 KB
testcase_12 AC 5 ms
13,616 KB
testcase_13 AC 20 ms
15,592 KB
testcase_14 AC 17 ms
15,056 KB
testcase_15 AC 32 ms
16,164 KB
testcase_16 AC 20 ms
15,348 KB
testcase_17 AC 20 ms
15,444 KB
testcase_18 AC 8 ms
14,612 KB
testcase_19 AC 20 ms
15,392 KB
testcase_20 AC 30 ms
15,624 KB
testcase_21 AC 24 ms
15,872 KB
testcase_22 AC 16 ms
14,716 KB
testcase_23 AC 48 ms
17,544 KB
testcase_24 AC 47 ms
16,424 KB
testcase_25 AC 60 ms
17,376 KB
testcase_26 AC 65 ms
18,176 KB
testcase_27 AC 50 ms
16,556 KB
testcase_28 AC 61 ms
19,148 KB
testcase_29 AC 62 ms
19,244 KB
testcase_30 AC 60 ms
18,832 KB
testcase_31 AC 60 ms
18,700 KB
testcase_32 AC 61 ms
19,112 KB
testcase_33 AC 59 ms
18,972 KB
testcase_34 AC 61 ms
19,108 KB
testcase_35 AC 61 ms
19,052 KB
testcase_36 AC 60 ms
19,140 KB
testcase_37 AC 60 ms
18,996 KB
testcase_38 AC 61 ms
19,096 KB
testcase_39 AC 60 ms
18,780 KB
testcase_40 AC 60 ms
18,720 KB
testcase_41 AC 60 ms
18,792 KB
testcase_42 AC 61 ms
19,160 KB
testcase_43 AC 62 ms
19,160 KB
testcase_44 AC 60 ms
18,796 KB
testcase_45 AC 62 ms
19,032 KB
testcase_46 AC 61 ms
18,832 KB
testcase_47 AC 109 ms
19,964 KB
testcase_48 AC 111 ms
19,880 KB
testcase_49 AC 109 ms
19,936 KB
testcase_50 AC 76 ms
19,612 KB
testcase_51 AC 107 ms
19,768 KB
testcase_52 AC 85 ms
19,456 KB
testcase_53 AC 84 ms
19,384 KB
testcase_54 AC 84 ms
19,556 KB
testcase_55 AC 85 ms
19,524 KB
testcase_56 AC 83 ms
19,580 KB
testcase_57 AC 78 ms
19,516 KB
testcase_58 AC 71 ms
19,616 KB
evil_aftercontest.txt AC 137 ms
26,048 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int N,M;
vector<pair<int,int> >G[3<<17];
long dist[3<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int k,c;cin>>k>>c;
		c++;
		for(int j=0;j<k;j++)
		{
			int s;cin>>s;
			s--;
			G[s].push_back(make_pair(N+i*2+s%2,s+c));
			G[N+i*2+s%2].push_back(make_pair(s,s+c));
		}
		G[N+i*2].push_back(make_pair(N+i*2+1,1));
		G[N+i*2+1].push_back(make_pair(N+i*2,1));
	}
	for(int i=0;i<N+2*M;i++)dist[i]=9e18;
	priority_queue<pair<long,int> >P;
	dist[0]=0;
	P.push(make_pair(0,0));
	while(!P.empty())
	{
		int u=P.top().second;
		long c=-P.top().first;
		P.pop();
		if(dist[u]<c)continue;
		for(pair<int,int>e:G[u])
		{
			int v=e.first;
			long nxt=c+e.second;
			if(dist[v]>nxt)
			{
				dist[v]=nxt;
				P.push(make_pair(-nxt,v));
			}
		}
	}
	long ans=dist[N-1];
	if(ans==(long)9e18)ans=-2;
	cout<<ans/2<<endl;
}
0