結果

問題 No.812 Change of Class
ユーザー hedwig100hedwig100
提出日時 2020-04-22 14:31:41
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 2,697 ms / 4,000 ms
コード長 642 bytes
コンパイル時間 98 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 31,344 KB
最終ジャッジ日時 2024-04-19 14:57:22
合計ジャッジ時間 61,709 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1,721 ms
28,000 KB
testcase_01 AC 286 ms
13,312 KB
testcase_02 AC 972 ms
19,968 KB
testcase_03 AC 2,069 ms
31,344 KB
testcase_04 AC 1,861 ms
29,112 KB
testcase_05 AC 2,697 ms
27,692 KB
testcase_06 AC 2,213 ms
25,120 KB
testcase_07 AC 58 ms
14,208 KB
testcase_08 AC 39 ms
11,904 KB
testcase_09 AC 2,259 ms
29,384 KB
testcase_10 AC 2,417 ms
29,640 KB
testcase_11 AC 165 ms
21,120 KB
testcase_12 AC 1,434 ms
27,632 KB
testcase_13 AC 27 ms
10,880 KB
testcase_14 AC 27 ms
10,752 KB
testcase_15 AC 1,646 ms
22,712 KB
testcase_16 AC 114 ms
11,648 KB
testcase_17 AC 1,444 ms
23,720 KB
testcase_18 AC 1,094 ms
20,388 KB
testcase_19 AC 1,229 ms
21,924 KB
testcase_20 AC 2,491 ms
28,952 KB
testcase_21 AC 1,031 ms
19,736 KB
testcase_22 AC 448 ms
14,976 KB
testcase_23 AC 99 ms
11,520 KB
testcase_24 AC 140 ms
11,904 KB
testcase_25 AC 337 ms
14,208 KB
testcase_26 AC 2,035 ms
26,028 KB
testcase_27 AC 1,745 ms
24,008 KB
testcase_28 AC 1,169 ms
21,852 KB
testcase_29 AC 279 ms
13,056 KB
testcase_30 AC 1,512 ms
23,560 KB
testcase_31 AC 1,319 ms
21,208 KB
testcase_32 AC 545 ms
16,128 KB
testcase_33 AC 1,697 ms
25,092 KB
testcase_34 AC 127 ms
11,776 KB
testcase_35 AC 299 ms
13,952 KB
testcase_36 AC 163 ms
12,032 KB
testcase_37 AC 858 ms
16,768 KB
testcase_38 AC 82 ms
15,360 KB
testcase_39 AC 863 ms
16,768 KB
testcase_40 AC 211 ms
12,672 KB
testcase_41 AC 70 ms
14,592 KB
testcase_42 AC 1,949 ms
22,656 KB
testcase_43 AC 263 ms
19,456 KB
testcase_44 AC 1,372 ms
19,328 KB
testcase_45 AC 166 ms
11,776 KB
testcase_46 AC 234 ms
19,456 KB
testcase_47 AC 1,307 ms
19,328 KB
testcase_48 AC 1,322 ms
21,376 KB
testcase_49 AC 379 ms
13,568 KB
testcase_50 AC 45 ms
11,008 KB
testcase_51 AC 309 ms
14,848 KB
testcase_52 AC 602 ms
20,096 KB
testcase_53 AC 270 ms
12,544 KB
testcase_54 AC 232 ms
12,416 KB
testcase_55 AC 1,323 ms
20,864 KB
testcase_56 AC 1,528 ms
23,296 KB
testcase_57 AC 1,566 ms
23,436 KB
testcase_58 AC 897 ms
17,664 KB
testcase_59 AC 1,821 ms
25,344 KB
testcase_60 AC 26 ms
10,752 KB
testcase_61 AC 27 ms
10,752 KB
testcase_62 AC 27 ms
10,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from  collections import deque

n,m = map(int,input().split())
G = [[] for _ in range(n)]
for _ in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    G[a].append(b)
    G[b].append(a)

q = int(input())
for _ in range(q):
    s = int(input())
    s -= 1
    dist = [-1] * n
    dist[s] = 0
    q = deque([s])
    ret = 0
    while q:
        p = q.popleft()
        for v in G[p]:
            if dist[v] >= 0:
                continue
            ret += 1
            dist[v] = dist[p] + 1
            q.append(v)
    D = max(dist)
    day = 0
    d = 1
    while d < D:
        d *= 2
        day += 1
    print(ret,day)

0