結果

問題 No.812 Change of Class
ユーザー kotatsugamekotatsugame
提出日時 2019-10-12 19:41:55
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 166 ms / 4,000 ms
コード長 673 bytes
コンパイル時間 1,464 ms
コンパイル使用メモリ 78,804 KB
実行使用メモリ 10,128 KB
最終ジャッジ日時 2023-09-03 15:42:31
合計ジャッジ時間 7,515 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
9,248 KB
testcase_01 AC 14 ms
6,844 KB
testcase_02 AC 39 ms
8,028 KB
testcase_03 AC 83 ms
9,700 KB
testcase_04 AC 74 ms
9,332 KB
testcase_05 AC 160 ms
9,404 KB
testcase_06 AC 143 ms
8,844 KB
testcase_07 AC 5 ms
6,544 KB
testcase_08 AC 5 ms
6,576 KB
testcase_09 AC 152 ms
9,676 KB
testcase_10 AC 158 ms
9,696 KB
testcase_11 AC 18 ms
7,596 KB
testcase_12 AC 109 ms
9,336 KB
testcase_13 AC 4 ms
6,524 KB
testcase_14 AC 3 ms
6,420 KB
testcase_15 AC 109 ms
8,536 KB
testcase_16 AC 10 ms
6,880 KB
testcase_17 AC 100 ms
8,776 KB
testcase_18 AC 79 ms
8,204 KB
testcase_19 AC 88 ms
8,352 KB
testcase_20 AC 166 ms
9,876 KB
testcase_21 AC 75 ms
8,004 KB
testcase_22 AC 36 ms
7,196 KB
testcase_23 AC 8 ms
6,584 KB
testcase_24 AC 12 ms
6,740 KB
testcase_25 AC 29 ms
7,008 KB
testcase_26 AC 137 ms
9,080 KB
testcase_27 AC 124 ms
8,936 KB
testcase_28 AC 90 ms
8,340 KB
testcase_29 AC 24 ms
6,856 KB
testcase_30 AC 110 ms
8,880 KB
testcase_31 AC 95 ms
8,228 KB
testcase_32 AC 47 ms
7,360 KB
testcase_33 AC 120 ms
8,984 KB
testcase_34 AC 11 ms
6,616 KB
testcase_35 AC 24 ms
7,012 KB
testcase_36 AC 11 ms
6,660 KB
testcase_37 AC 54 ms
7,652 KB
testcase_38 AC 9 ms
6,888 KB
testcase_39 AC 51 ms
7,560 KB
testcase_40 AC 16 ms
6,976 KB
testcase_41 AC 8 ms
6,712 KB
testcase_42 AC 101 ms
8,676 KB
testcase_43 AC 31 ms
8,020 KB
testcase_44 AC 75 ms
8,168 KB
testcase_45 AC 11 ms
6,760 KB
testcase_46 AC 31 ms
7,868 KB
testcase_47 AC 73 ms
8,184 KB
testcase_48 AC 82 ms
8,468 KB
testcase_49 AC 22 ms
6,980 KB
testcase_50 AC 5 ms
6,432 KB
testcase_51 AC 26 ms
7,200 KB
testcase_52 AC 53 ms
8,100 KB
testcase_53 AC 17 ms
6,816 KB
testcase_54 AC 15 ms
6,756 KB
testcase_55 AC 56 ms
9,092 KB
testcase_56 AC 68 ms
9,440 KB
testcase_57 AC 67 ms
9,792 KB
testcase_58 AC 37 ms
7,948 KB
testcase_59 AC 79 ms
10,128 KB
testcase_60 AC 4 ms
6,400 KB
testcase_61 AC 4 ms
6,464 KB
testcase_62 AC 4 ms
6,712 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
int N,M;
vector<int>G[1<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int u,v;cin>>u>>v;
		u--,v--;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	int Q;cin>>Q;
	for(;Q--;)
	{
		int A;cin>>A;A--;
		vector<int>dis(N,1e9);
		dis[A]=0;
		queue<int>P;
		P.push(A);
		while(!P.empty())
		{
			int u=P.front();P.pop();
			for(int v:G[u])
			{
				if(dis[v]>dis[u]+1)
				{
					dis[v]=dis[u]+1;
					P.push(v);
				}
			}
		}
		int x=0,cnt=0;
		for(int i=0;i<N;i++)
		{
			if(dis[i]<1e9)x=max(x,dis[i]),cnt++;
		}
		int L=0;
		while(x>1<<L)L++;
		cout<<cnt-1<<" "<<L<<endl;
	}
}
0