結果

問題 No.812 Change of Class
ユーザー O2MTO2MT
提出日時 2020-09-01 22:45:33
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 605 bytes
コンパイル時間 305 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 30,592 KB
最終ジャッジ日時 2024-05-01 20:05:02
合計ジャッジ時間 24,905 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3,398 ms
28,028 KB
testcase_01 AC 553 ms
13,440 KB
testcase_02 AC 1,904 ms
19,968 KB
testcase_03 AC 3,984 ms
30,592 KB
testcase_04 AC 3,636 ms
28,304 KB
testcase_05 TLE -
testcase_06 AC 3,878 ms
25,152 KB
testcase_07 AC 171 ms
14,336 KB
testcase_08 AC 86 ms
12,032 KB
testcase_09 TLE -
testcase_10 TLE -
testcase_11 AC 453 ms
21,376 KB
testcase_12 AC 2,634 ms
27,680 KB
testcase_13 AC 31 ms
10,880 KB
testcase_14 AC 30 ms
10,880 KB
testcase_15 AC 3,053 ms
22,820 KB
testcase_16 AC 191 ms
11,776 KB
testcase_17 AC 2,859 ms
23,756 KB
testcase_18 AC 2,094 ms
20,300 KB
testcase_19 AC 2,326 ms
21,832 KB
testcase_20 TLE -
testcase_21 AC 2,005 ms
19,896 KB
testcase_22 AC 813 ms
15,104 KB
testcase_23 AC 158 ms
11,648 KB
testcase_24 AC 233 ms
11,904 KB
testcase_25 AC 672 ms
14,080 KB
testcase_26 TLE -
testcase_27 AC 3,287 ms
24,228 KB
testcase_28 AC 2,312 ms
21,956 KB
testcase_29 AC 508 ms
13,056 KB
testcase_30 AC 3,015 ms
23,604 KB
testcase_31 AC 2,702 ms
21,252 KB
testcase_32 AC 1,102 ms
16,324 KB
testcase_33 AC 3,205 ms
25,232 KB
testcase_34 AC 214 ms
11,904 KB
testcase_35 AC 606 ms
14,080 KB
testcase_36 AC 283 ms
12,160 KB
testcase_37 AC 1,698 ms
16,896 KB
testcase_38 AC 217 ms
15,360 KB
testcase_39 AC 1,742 ms
16,896 KB
testcase_40 AC 391 ms
12,672 KB
testcase_41 AC 189 ms
14,720 KB
testcase_42 AC 3,513 ms
22,656 KB
testcase_43 AC 529 ms
19,584 KB
testcase_44 AC 2,568 ms
19,200 KB
testcase_45 AC 288 ms
11,904 KB
testcase_46 AC 465 ms
19,328 KB
testcase_47 AC 2,454 ms
19,456 KB
testcase_48 AC 2,418 ms
21,376 KB
testcase_49 AC 736 ms
13,696 KB
testcase_50 AC 67 ms
11,008 KB
testcase_51 AC 628 ms
14,976 KB
testcase_52 AC 1,187 ms
20,096 KB
testcase_53 AC 485 ms
12,544 KB
testcase_54 AC 441 ms
12,544 KB
testcase_55 AC 2,527 ms
21,476 KB
testcase_56 AC 3,024 ms
23,432 KB
testcase_57 AC 3,193 ms
24,572 KB
testcase_58 AC 1,710 ms
17,816 KB
testcase_59 AC 3,729 ms
26,728 KB
testcase_60 AC 31 ms
10,880 KB
testcase_61 AC 30 ms
10,752 KB
testcase_62 AC 30 ms
10,752 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