結果

問題 No.812 Change of Class
ユーザー 👑 kmjpkmjp
提出日時 2019-04-13 00:44:29
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 150 ms / 4,000 ms
コード長 1,200 bytes
コンパイル時間 3,790 ms
コンパイル使用メモリ 171,732 KB
実行使用メモリ 9,416 KB
最終ジャッジ日時 2023-09-03 14:22:15
合計ジャッジ時間 7,060 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
8,540 KB
testcase_01 AC 9 ms
6,144 KB
testcase_02 AC 25 ms
7,256 KB
testcase_03 AC 51 ms
8,980 KB
testcase_04 AC 46 ms
8,608 KB
testcase_05 AC 150 ms
8,624 KB
testcase_06 AC 123 ms
8,120 KB
testcase_07 AC 4 ms
6,164 KB
testcase_08 AC 4 ms
5,792 KB
testcase_09 AC 127 ms
9,020 KB
testcase_10 AC 135 ms
8,932 KB
testcase_11 AC 11 ms
6,880 KB
testcase_12 AC 83 ms
8,888 KB
testcase_13 AC 4 ms
5,732 KB
testcase_14 AC 3 ms
5,740 KB
testcase_15 AC 92 ms
7,824 KB
testcase_16 AC 9 ms
5,876 KB
testcase_17 AC 84 ms
7,976 KB
testcase_18 AC 64 ms
7,396 KB
testcase_19 AC 73 ms
7,740 KB
testcase_20 AC 137 ms
8,868 KB
testcase_21 AC 61 ms
7,364 KB
testcase_22 AC 29 ms
6,540 KB
testcase_23 AC 7 ms
6,008 KB
testcase_24 AC 10 ms
5,932 KB
testcase_25 AC 24 ms
6,272 KB
testcase_26 AC 112 ms
8,352 KB
testcase_27 AC 101 ms
8,040 KB
testcase_28 AC 69 ms
7,592 KB
testcase_29 AC 18 ms
6,112 KB
testcase_30 AC 88 ms
7,996 KB
testcase_31 AC 76 ms
7,648 KB
testcase_32 AC 35 ms
6,732 KB
testcase_33 AC 94 ms
8,356 KB
testcase_34 AC 10 ms
5,916 KB
testcase_35 AC 19 ms
6,276 KB
testcase_36 AC 10 ms
5,916 KB
testcase_37 AC 44 ms
6,876 KB
testcase_38 AC 5 ms
6,100 KB
testcase_39 AC 45 ms
7,104 KB
testcase_40 AC 13 ms
6,060 KB
testcase_41 AC 6 ms
6,008 KB
testcase_42 AC 91 ms
8,040 KB
testcase_43 AC 20 ms
7,220 KB
testcase_44 AC 64 ms
7,392 KB
testcase_45 AC 9 ms
5,920 KB
testcase_46 AC 18 ms
7,132 KB
testcase_47 AC 64 ms
7,468 KB
testcase_48 AC 68 ms
7,716 KB
testcase_49 AC 20 ms
6,280 KB
testcase_50 AC 4 ms
5,788 KB
testcase_51 AC 20 ms
6,448 KB
testcase_52 AC 38 ms
7,432 KB
testcase_53 AC 14 ms
6,068 KB
testcase_54 AC 12 ms
6,052 KB
testcase_55 AC 35 ms
8,316 KB
testcase_56 AC 41 ms
8,772 KB
testcase_57 AC 42 ms
8,880 KB
testcase_58 AC 23 ms
7,344 KB
testcase_59 AC 48 ms
9,416 KB
testcase_60 AC 3 ms
5,932 KB
testcase_61 AC 3 ms
5,752 KB
testcase_62 AC 3 ms
5,672 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,M,Q;
vector<int> E[101010];
int D[101010];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>M;
	FOR(i,M) {
		cin>>x>>y;
		E[x].push_back(y);
		E[y].push_back(x);
	}
	cin>>Q;
	FOR(i,Q) {
		cin>>x;
		FOR(j,N) D[j+1]=1<<20;
		int num=0,ma=0;
		D[x]=0;
		queue<int> QQ;
		QQ.push(x);
		while(QQ.size()) {
			y=QQ.front();
			QQ.pop();
			num++;
			ma=max(ma,D[y]);
			FORR(e,E[y]) if(D[e]>D[y]+1) {
				D[e]=D[y]+1;
				QQ.push(e);
			}
		}
		int ret=0;
		while(1<<ret<ma) ret++;
		cout<<num-1<<" "<<ret<<endl;
	}
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0