結果

問題 No.812 Change of Class
ユーザー O2MTO2MT
提出日時 2020-09-01 22:46:21
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,360 ms / 4,000 ms
コード長 605 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 81,948 KB
実行使用メモリ 105,144 KB
最終ジャッジ日時 2024-04-30 21:54:26
合計ジャッジ時間 31,012 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 434 ms
93,972 KB
testcase_01 AC 148 ms
78,960 KB
testcase_02 AC 283 ms
87,412 KB
testcase_03 AC 494 ms
96,796 KB
testcase_04 AC 448 ms
94,604 KB
testcase_05 AC 1,360 ms
95,932 KB
testcase_06 AC 1,075 ms
92,360 KB
testcase_07 AC 62 ms
72,604 KB
testcase_08 AC 51 ms
66,236 KB
testcase_09 AC 1,238 ms
100,740 KB
testcase_10 AC 1,215 ms
99,876 KB
testcase_11 AC 126 ms
105,144 KB
testcase_12 AC 682 ms
102,112 KB
testcase_13 AC 46 ms
55,024 KB
testcase_14 AC 45 ms
55,264 KB
testcase_15 AC 891 ms
93,540 KB
testcase_16 AC 128 ms
78,152 KB
testcase_17 AC 779 ms
94,008 KB
testcase_18 AC 571 ms
90,524 KB
testcase_19 AC 647 ms
92,896 KB
testcase_20 AC 1,266 ms
98,756 KB
testcase_21 AC 536 ms
89,888 KB
testcase_22 AC 269 ms
85,664 KB
testcase_23 AC 124 ms
78,348 KB
testcase_24 AC 143 ms
78,448 KB
testcase_25 AC 225 ms
83,332 KB
testcase_26 AC 1,090 ms
97,060 KB
testcase_27 AC 967 ms
94,268 KB
testcase_28 AC 633 ms
91,136 KB
testcase_29 AC 181 ms
79,360 KB
testcase_30 AC 811 ms
92,768 KB
testcase_31 AC 550 ms
90,640 KB
testcase_32 AC 307 ms
85,848 KB
testcase_33 AC 725 ms
95,820 KB
testcase_34 AC 139 ms
78,824 KB
testcase_35 AC 207 ms
83,456 KB
testcase_36 AC 140 ms
78,544 KB
testcase_37 AC 426 ms
86,036 KB
testcase_38 AC 94 ms
85,300 KB
testcase_39 AC 406 ms
87,028 KB
testcase_40 AC 179 ms
79,384 KB
testcase_41 AC 87 ms
83,196 KB
testcase_42 AC 995 ms
91,756 KB
testcase_43 AC 214 ms
97,652 KB
testcase_44 AC 647 ms
88,212 KB
testcase_45 AC 144 ms
78,728 KB
testcase_46 AC 187 ms
96,332 KB
testcase_47 AC 644 ms
88,116 KB
testcase_48 AC 613 ms
92,344 KB
testcase_49 AC 219 ms
79,880 KB
testcase_50 AC 77 ms
72,796 KB
testcase_51 AC 212 ms
85,716 KB
testcase_52 AC 367 ms
94,584 KB
testcase_53 AC 176 ms
78,604 KB
testcase_54 AC 168 ms
78,904 KB
testcase_55 AC 379 ms
96,512 KB
testcase_56 AC 412 ms
98,720 KB
testcase_57 AC 433 ms
98,620 KB
testcase_58 AC 273 ms
89,300 KB
testcase_59 AC 476 ms
102,476 KB
testcase_60 AC 42 ms
55,528 KB
testcase_61 AC 43 ms
55,288 KB
testcase_62 AC 42 ms
54,388 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
from math import *
N,M = map(int,input().split())
l = [[]for _ in range(N+1)]

for _ in range(M):
  p,q = map(int,input().split())
  l[p].append(q)
  l[q].append(p)

Q = int(input())
for _ in range(Q):
  i = int(input())
  que = deque([i])
  check = [-1]*(N+1)
  check[i] = 0
  friends,days = 0,-1
  while que:
    num = que.popleft()
    for j in l[num]:
      if check[j] == -1:
        que.append(j)
        check[j] = check[num]+1
        friends += 1
  ans = 0
  for k in range(1,N+1):
    if check[k] >= 2:
      ans = max(ans,ceil(log2(check[k])))
  print(friends,ans)
0