結果

問題 No.812 Change of Class
ユーザー McGregorshMcGregorsh
提出日時 2023-07-07 13:09:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,077 ms / 4,000 ms
コード長 2,161 bytes
コンパイル時間 891 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 143,840 KB
最終ジャッジ日時 2023-09-28 13:38:03
合計ジャッジ時間 34,904 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 436 ms
110,900 KB
testcase_01 AC 280 ms
93,172 KB
testcase_02 AC 353 ms
103,832 KB
testcase_03 AC 457 ms
113,176 KB
testcase_04 AC 438 ms
111,376 KB
testcase_05 AC 1,018 ms
113,744 KB
testcase_06 AC 782 ms
109,308 KB
testcase_07 AC 265 ms
108,936 KB
testcase_08 AC 247 ms
90,640 KB
testcase_09 AC 951 ms
118,368 KB
testcase_10 AC 1,014 ms
117,304 KB
testcase_11 AC 331 ms
143,840 KB
testcase_12 AC 736 ms
121,788 KB
testcase_13 AC 238 ms
90,552 KB
testcase_14 AC 240 ms
90,636 KB
testcase_15 AC 710 ms
110,288 KB
testcase_16 AC 283 ms
92,324 KB
testcase_17 AC 717 ms
109,912 KB
testcase_18 AC 570 ms
107,740 KB
testcase_19 AC 637 ms
107,956 KB
testcase_20 AC 1,077 ms
114,880 KB
testcase_21 AC 623 ms
105,968 KB
testcase_22 AC 374 ms
102,052 KB
testcase_23 AC 284 ms
92,564 KB
testcase_24 AC 291 ms
92,908 KB
testcase_25 AC 347 ms
98,608 KB
testcase_26 AC 972 ms
114,596 KB
testcase_27 AC 916 ms
110,748 KB
testcase_28 AC 631 ms
108,128 KB
testcase_29 AC 328 ms
93,712 KB
testcase_30 AC 824 ms
108,968 KB
testcase_31 AC 687 ms
105,540 KB
testcase_32 AC 403 ms
103,788 KB
testcase_33 AC 834 ms
113,248 KB
testcase_34 AC 289 ms
92,908 KB
testcase_35 AC 328 ms
100,788 KB
testcase_36 AC 285 ms
92,900 KB
testcase_37 AC 468 ms
101,692 KB
testcase_38 AC 283 ms
112,708 KB
testcase_39 AC 427 ms
104,700 KB
testcase_40 AC 307 ms
93,184 KB
testcase_41 AC 274 ms
110,272 KB
testcase_42 AC 788 ms
108,048 KB
testcase_43 AC 364 ms
115,088 KB
testcase_44 AC 509 ms
106,856 KB
testcase_45 AC 283 ms
92,824 KB
testcase_46 AC 344 ms
122,704 KB
testcase_47 AC 515 ms
107,172 KB
testcase_48 AC 631 ms
108,700 KB
testcase_49 AC 315 ms
93,776 KB
testcase_50 AC 249 ms
90,884 KB
testcase_51 AC 347 ms
100,764 KB
testcase_52 AC 468 ms
112,644 KB
testcase_53 AC 308 ms
93,580 KB
testcase_54 AC 295 ms
93,192 KB
testcase_55 AC 400 ms
112,304 KB
testcase_56 AC 423 ms
115,564 KB
testcase_57 AC 438 ms
119,712 KB
testcase_58 AC 357 ms
105,436 KB
testcase_59 AC 465 ms
123,340 KB
testcase_60 AC 235 ms
89,984 KB
testcase_61 AC 238 ms
89,816 KB
testcase_62 AC 236 ms
90,120 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from sys import stdin
from fractions import Fraction
import math
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque, defaultdict
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement, permutations
from bisect import bisect, bisect_left, bisect_right
from functools import reduce, lru_cache
from decimal import Decimal, getcontext, ROUND_HALF_UP
def i_input(): return int(stdin.readline())
def i_map(): return map(int, stdin.readline().split())
def i_list(): return list(i_map())
def s_input(): return stdin.readline()[:-1]
def s_map(): return s_input().split()
def s_list(): return list(s_map())
def lcm(a, b): return a * b // gcd(a, b)
def get_distance(x1, y1, x2, y2):
	  d = sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2)
	  return d
def rotate(table):
   	  n_fild = []
   	  for x in zip(*table[::-1]):
   	  	  n_fild.append(x)
   	  return n_fild
sys.setrecursionlimit(10 ** 7)
INF = float('inf')
MOD = 10 ** 9 + 7
MOD2 = 998244353
alpa = 'abcdefghijklmnopqrstuvwxyz'
ALPA = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'


def main():
   
   N, M = i_map()
   nums = [[] for i in range(N)]
   
   for i in range(M):
   	  a, b = i_map()
   	  a -= 1
   	  b -= 1
   	  nums[a].append(b)
   	  nums[b].append(a)
   
   Q = int(input())
   for i in range(Q):
   	  p = int(input())
   	  p -= 1
   	  dist = [-INF] * N
   	  dist[p] = 0
   	  que = deque()
   	  que.append(p)
   	  while que:
   	  	  now = que.popleft()
   	  	  for nxt in nums[now]:
   	  	  	  if dist[nxt] == -INF:
   	  	  	  	  dist[nxt] = dist[now] + 1
   	  	  	  	  que.append(nxt)
   	  
   	  ans1 = 0
   	  for j in range(N):
   	  	  if dist[j] > 0 and dist[j] != -INF:
   	  	  	  ans1 += 1
   	  maxnum = max(dist)
   	  
   	  if maxnum == 1:
   	  	  ans2 = 0
   	  else:
   	  	  ans2 = 0
   	  	  for k in range(100):
   	  	  	  l = 2 ** k
   	  	  	  r = 2 ** (k+1)
   	  	  	  if k < maxnum <= r:
   	  	  	  	  ans2 = k+1
   	  	  	  	  break
   	  
   	  print(ans1, ans2)
   
   
if __name__ == '__main__':
    main()












0