結果

問題 No.812 Change of Class
ユーザー FF256grhyFF256grhy
提出日時 2019-04-12 22:46:17
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,254 bytes
コンパイル時間 1,660 ms
コンパイル使用メモリ 167,168 KB
実行使用メモリ 11,676 KB
最終ジャッジ日時 2023-09-03 13:51:39
合計ジャッジ時間 8,737 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
10,716 KB
testcase_01 AC 14 ms
6,440 KB
testcase_02 AC 42 ms
8,516 KB
testcase_03 AC 91 ms
11,676 KB
testcase_04 AC 81 ms
11,052 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 4 ms
5,724 KB
testcase_08 AC 3 ms
5,828 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 14 ms
6,572 KB
testcase_12 WA -
testcase_13 AC 3 ms
5,692 KB
testcase_14 AC 3 ms
5,752 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 AC 25 ms
6,260 KB
testcase_36 AC 11 ms
5,936 KB
testcase_37 AC 63 ms
6,804 KB
testcase_38 AC 6 ms
5,948 KB
testcase_39 AC 65 ms
6,936 KB
testcase_40 AC 16 ms
6,020 KB
testcase_41 AC 5 ms
6,144 KB
testcase_42 AC 138 ms
7,756 KB
testcase_43 AC 33 ms
7,020 KB
testcase_44 AC 94 ms
7,192 KB
testcase_45 AC 11 ms
5,892 KB
testcase_46 AC 30 ms
7,036 KB
testcase_47 AC 93 ms
7,468 KB
testcase_48 AC 101 ms
7,740 KB
testcase_49 AC 25 ms
6,244 KB
testcase_50 AC 5 ms
5,792 KB
testcase_51 AC 30 ms
6,412 KB
testcase_52 AC 58 ms
7,164 KB
testcase_53 AC 17 ms
6,020 KB
testcase_54 AC 14 ms
5,992 KB
testcase_55 AC 46 ms
7,900 KB
testcase_56 AC 54 ms
8,156 KB
testcase_57 AC 57 ms
8,416 KB
testcase_58 AC 31 ms
7,044 KB
testcase_59 AC 65 ms
8,668 KB
testcase_60 AC 4 ms
5,816 KB
testcase_61 AC 4 ms
5,684 KB
testcase_62 AC 3 ms
5,760 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 c, dma;
bool vis[100000];
void dfs(int v, int d) {
	if(exchange(vis[v], true)) { return; }
	c++;
	setmax(dma, d);
	RF(e, g[v]) { dfs(e, d + 1); }
}

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(i, q) {
		int a;
		cin >> a;
		a--;
		
		c = 0, dma = 0;
		inc(i, n) { vis[i] = false; }
		dfs(a, 0);
		
		cout << c - 1 << " " << f(dma) << "\n";
	}
	
	return 0;
}
0