結果

問題 No.812 Change of Class
ユーザー rookzenorookzeno
提出日時 2019-04-12 22:15:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,887 ms / 4,000 ms
コード長 887 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 86,860 KB
実行使用メモリ 271,016 KB
最終ジャッジ日時 2023-09-03 13:06:03
合計ジャッジ時間 42,173 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 617 ms
132,160 KB
testcase_01 AC 209 ms
82,180 KB
testcase_02 AC 412 ms
106,704 KB
testcase_03 AC 668 ms
141,540 KB
testcase_04 AC 633 ms
132,752 KB
testcase_05 AC 1,887 ms
210,048 KB
testcase_06 AC 1,599 ms
188,788 KB
testcase_07 AC 124 ms
95,788 KB
testcase_08 AC 105 ms
76,844 KB
testcase_09 AC 1,660 ms
186,996 KB
testcase_10 AC 1,683 ms
191,060 KB
testcase_11 AC 162 ms
126,896 KB
testcase_12 AC 1,055 ms
138,352 KB
testcase_13 AC 93 ms
71,752 KB
testcase_14 AC 94 ms
71,384 KB
testcase_15 AC 1,145 ms
147,728 KB
testcase_16 AC 189 ms
79,876 KB
testcase_17 AC 1,022 ms
140,064 KB
testcase_18 AC 776 ms
122,144 KB
testcase_19 AC 812 ms
129,508 KB
testcase_20 AC 1,755 ms
195,604 KB
testcase_21 AC 820 ms
119,652 KB
testcase_22 AC 344 ms
91,536 KB
testcase_23 AC 168 ms
79,244 KB
testcase_24 AC 188 ms
79,728 KB
testcase_25 AC 292 ms
87,816 KB
testcase_26 AC 1,460 ms
168,956 KB
testcase_27 AC 1,374 ms
154,660 KB
testcase_28 AC 852 ms
127,904 KB
testcase_29 AC 257 ms
83,472 KB
testcase_30 AC 1,138 ms
144,640 KB
testcase_31 AC 1,068 ms
134,640 KB
testcase_32 AC 443 ms
97,144 KB
testcase_33 AC 1,140 ms
149,388 KB
testcase_34 AC 191 ms
79,828 KB
testcase_35 AC 272 ms
85,428 KB
testcase_36 AC 203 ms
80,432 KB
testcase_37 AC 588 ms
102,692 KB
testcase_38 AC 134 ms
99,692 KB
testcase_39 AC 551 ms
103,584 KB
testcase_40 AC 224 ms
81,984 KB
testcase_41 AC 130 ms
97,436 KB
testcase_42 AC 1,211 ms
133,328 KB
testcase_43 AC 234 ms
96,472 KB
testcase_44 AC 798 ms
115,816 KB
testcase_45 AC 198 ms
80,088 KB
testcase_46 AC 233 ms
105,600 KB
testcase_47 AC 736 ms
115,624 KB
testcase_48 AC 868 ms
117,876 KB
testcase_49 AC 289 ms
85,984 KB
testcase_50 AC 125 ms
77,656 KB
testcase_51 AC 282 ms
87,756 KB
testcase_52 AC 516 ms
103,584 KB
testcase_53 AC 240 ms
81,980 KB
testcase_54 AC 217 ms
81,488 KB
testcase_55 AC 689 ms
262,552 KB
testcase_56 AC 790 ms
268,148 KB
testcase_57 AC 813 ms
271,016 KB
testcase_58 AC 441 ms
170,132 KB
testcase_59 AC 878 ms
268,368 KB
testcase_60 AC 91 ms
71,840 KB
testcase_61 AC 92 ms
71,496 KB
testcase_62 AC 93 ms
71,472 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
from collections import deque
sys.setrecursionlimit(20000000)
input = sys.stdin.readline
n,m = map(int,input().split())
g = [[] for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a-=1;b-=1
    g[a].append(b)
    g[b].append(a)
q = int(input())
a = []
for i in range(q):
    a.append(int(input())-1)
kyori = [1<<30]*n
ok = [0]*n
def dfs(x,y):
    for i in g[x]:
        if kyori[i] > y+1:
            kyori[i] = y+1
            ok[i] = 1
            que.append([i,y+1])
for i in range(q):
    b = a[i]
    kyori = [1<<30]*n
    ok = [0]*n
    ok[b] = 1
    kyori[b] = 0
    que = deque([[b,0]])
    while que:
        x,y = que.popleft()
        dfs(x,y)
    ans = 0
    for j in kyori:
        if j != 1<<30:
            ans = max(ans,j)
    ans2 = 0
    if ans:
        ans-=1
    while ans:
        ans//=2
        ans2+=1
    print(sum(ok)-1,ans2)
0