結果

問題 No.812 Change of Class
ユーザー FF256grhyFF256grhy
提出日時 2019-04-12 22:56:06
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 171 ms / 4,000 ms
コード長 2,304 bytes
コンパイル時間 1,700 ms
コンパイル使用メモリ 171,456 KB
実行使用メモリ 9,488 KB
最終ジャッジ日時 2023-09-03 14:01:31
合計ジャッジ時間 7,721 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
8,504 KB
testcase_01 AC 13 ms
6,288 KB
testcase_02 AC 40 ms
7,280 KB
testcase_03 AC 83 ms
9,108 KB
testcase_04 AC 73 ms
8,660 KB
testcase_05 AC 171 ms
8,624 KB
testcase_06 AC 151 ms
8,176 KB
testcase_07 AC 4 ms
5,832 KB
testcase_08 AC 3 ms
5,744 KB
testcase_09 AC 156 ms
9,016 KB
testcase_10 AC 160 ms
9,208 KB
testcase_11 AC 16 ms
6,860 KB
testcase_12 AC 106 ms
8,608 KB
testcase_13 AC 3 ms
5,868 KB
testcase_14 AC 3 ms
5,712 KB
testcase_15 AC 112 ms
7,848 KB
testcase_16 AC 10 ms
5,872 KB
testcase_17 AC 110 ms
8,080 KB
testcase_18 AC 80 ms
7,340 KB
testcase_19 AC 93 ms
7,608 KB
testcase_20 AC 168 ms
8,852 KB
testcase_21 AC 78 ms
7,340 KB
testcase_22 AC 35 ms
6,444 KB
testcase_23 AC 8 ms
5,832 KB
testcase_24 AC 12 ms
5,908 KB
testcase_25 AC 28 ms
6,304 KB
testcase_26 AC 136 ms
8,412 KB
testcase_27 AC 122 ms
8,012 KB
testcase_28 AC 88 ms
7,596 KB
testcase_29 AC 21 ms
6,232 KB
testcase_30 AC 110 ms
7,904 KB
testcase_31 AC 98 ms
7,840 KB
testcase_32 AC 46 ms
6,640 KB
testcase_33 AC 121 ms
8,196 KB
testcase_34 AC 11 ms
5,912 KB
testcase_35 AC 24 ms
6,268 KB
testcase_36 AC 11 ms
5,936 KB
testcase_37 AC 55 ms
6,940 KB
testcase_38 AC 7 ms
6,284 KB
testcase_39 AC 57 ms
7,128 KB
testcase_40 AC 16 ms
6,064 KB
testcase_41 AC 6 ms
6,008 KB
testcase_42 AC 115 ms
8,140 KB
testcase_43 AC 33 ms
7,512 KB
testcase_44 AC 81 ms
7,356 KB
testcase_45 AC 12 ms
6,116 KB
testcase_46 AC 30 ms
7,136 KB
testcase_47 AC 78 ms
7,340 KB
testcase_48 AC 86 ms
7,744 KB
testcase_49 AC 24 ms
6,324 KB
testcase_50 AC 4 ms
5,732 KB
testcase_51 AC 27 ms
6,444 KB
testcase_52 AC 52 ms
7,440 KB
testcase_53 AC 17 ms
6,076 KB
testcase_54 AC 14 ms
6,156 KB
testcase_55 AC 56 ms
8,228 KB
testcase_56 AC 65 ms
8,896 KB
testcase_57 AC 69 ms
8,888 KB
testcase_58 AC 37 ms
7,308 KB
testcase_59 AC 79 ms
9,488 KB
testcase_60 AC 3 ms
5,752 KB
testcase_61 AC 4 ms
5,696 KB
testcase_62 AC 4 ms
5,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incII(i, l, r) for(int i = (l)    ; i <= (r); ++i)
#define incID(i, l, r) for(int i = (l)    ; i <  (r); ++i)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); --i)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC(T, v) static_cast<T>(v)
#define SI(v) SC(int, v.size())
#define SL(v) SC( LL, v.size())
#define RF(e, v) for(auto & e: v)
#define ei else if
#define UR assert(false)

// ---- ----

int n, m, Q;
vector<int> g[100000];

int f(int x) {
	int c = 0;
	while(! (x <= (1 << c))) { c++; }
	return c;
}

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[a].PB(b);
		g[b].PB(a);
	}
	cin >> Q;
	inc(QQ, Q) {
		int a;
		cin >> a;
		a--;
		
		int c = 0, dma = 0;
		vector<int> d(n, n);
		queue<int> q;
		q.push(a);
		d[a] = 0;
		c++;
		while(! q.empty()) {
			int p = q.front(); q.pop();
			RF(e, g[p]) {
				if(d[e] == n) { c++; }
				if(setmin(d[e], d[p] + 1)) { q.push(e); setmax(dma, d[e]); }
			}
		}
		
		cout << c - 1 << " " << f(dma) << "\n";
	}
	
	return 0;
}
0