結果

問題 No.812 Change of Class
ユーザー 双六双六
提出日時 2020-08-27 18:46:57
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,242 bytes
コンパイル時間 158 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 127,616 KB
最終ジャッジ日時 2024-04-25 12:05:02
合計ジャッジ時間 21,463 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 297 ms
103,424 KB
testcase_01 AC 118 ms
78,848 KB
testcase_02 AC 198 ms
90,368 KB
testcase_03 AC 328 ms
107,904 KB
testcase_04 AC 300 ms
101,888 KB
testcase_05 WA -
testcase_06 AC 529 ms
98,176 KB
testcase_07 AC 67 ms
77,696 KB
testcase_08 AC 55 ms
66,176 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 45 ms
54,144 KB
testcase_14 AC 44 ms
54,272 KB
testcase_15 AC 492 ms
96,000 KB
testcase_16 AC 112 ms
77,568 KB
testcase_17 AC 492 ms
98,432 KB
testcase_18 AC 378 ms
93,056 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 680 ms
102,656 KB
testcase_27 AC 628 ms
99,072 KB
testcase_28 WA -
testcase_29 AC 154 ms
78,848 KB
testcase_30 WA -
testcase_31 AC 453 ms
94,464 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 112 ms
78,080 KB
testcase_37 AC 284 ms
88,448 KB
testcase_38 WA -
testcase_39 AC 263 ms
89,728 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 593 ms
98,816 KB
testcase_43 WA -
testcase_44 AC 367 ms
94,592 KB
testcase_45 AC 124 ms
77,952 KB
testcase_46 WA -
testcase_47 AC 380 ms
93,952 KB
testcase_48 AC 415 ms
95,360 KB
testcase_49 AC 161 ms
80,128 KB
testcase_50 AC 73 ms
69,888 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 133 ms
78,976 KB
testcase_54 AC 124 ms
78,080 KB
testcase_55 AC 249 ms
102,016 KB
testcase_56 AC 280 ms
109,568 KB
testcase_57 AC 301 ms
111,104 KB
testcase_58 AC 202 ms
92,416 KB
testcase_59 AC 341 ms
115,456 KB
testcase_60 WA -
testcase_61 AC 43 ms
54,144 KB
testcase_62 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys; input = sys.stdin.buffer.readline
sys.setrecursionlimit(10**7)
from collections import defaultdict
from collections import deque
con = 10 ** 9 + 7; INF = float("inf")

def getlist():
	return list(map(int, input().split()))

class Graph(object):
	def __init__(self):
		self.graph = defaultdict(list)

	def __len__(self):
		return len(self.graph)

	def add_edge(self, a, b):
		self.graph[a].append(b)

class BFS(object):
	def __init__(self, graph, s, N):
		self.g = graph.graph
		self.Q = deque(); self.Q.append(s)
		self.dist = [INF] * N; self.dist[s] = 0
		while self.Q:
			v = self.Q.popleft()
			for i in self.g[v]:
				if self.dist[i] == INF:
					self.dist[i] = self.dist[v] + 1
					self.Q.append(i)

#処理内容
def main():
	N, M = getlist()
	G = Graph()
	for i in range(M):
		a, b = getlist()
		a -= 1; b -= 1
		G.add_edge(a, b)
		G.add_edge(b, a)

	Q = int(input())
	for _ in range(Q):
		A = int(input())
		A -= 1

		BF = BFS(G, A, N)
		cnt = 0
		MAX = 0
		for i in range(N):
			d = BF.dist[i] 
			if d != INF:
				cnt += 1
				MAX = max(MAX, d)
		cnt -= 1

		if MAX == 0:
			day = 0
		else:
			for i in range(1, 50):
				if 2 ** i >= MAX:
					day = i
					break

		print(cnt, day)
	

if __name__ == '__main__':
	main()
0