結果

問題 No.812 Change of Class
ユーザー neterukunneterukun
提出日時 2019-06-14 18:53:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 898 bytes
コンパイル時間 500 ms
コンパイル使用メモリ 86,932 KB
実行使用メモリ 197,048 KB
最終ジャッジ日時 2023-09-03 15:37:23
合計ジャッジ時間 23,748 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 332 ms
109,732 KB
testcase_01 AC 150 ms
81,304 KB
testcase_02 AC 245 ms
92,836 KB
testcase_03 AC 390 ms
118,248 KB
testcase_04 AC 346 ms
111,296 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 AC 161 ms
79,880 KB
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 333 ms
89,156 KB
testcase_40 WA -
testcase_41 WA -
testcase_42 AC 535 ms
104,316 KB
testcase_43 WA -
testcase_44 AC 391 ms
95,248 KB
testcase_45 AC 164 ms
79,960 KB
testcase_46 WA -
testcase_47 WA -
testcase_48 WA -
testcase_49 AC 207 ms
82,220 KB
testcase_50 AC 112 ms
77,552 KB
testcase_51 WA -
testcase_52 WA -
testcase_53 AC 175 ms
81,272 KB
testcase_54 AC 174 ms
80,376 KB
testcase_55 AC 360 ms
142,472 KB
testcase_56 AC 413 ms
163,516 KB
testcase_57 AC 430 ms
167,708 KB
testcase_58 AC 250 ms
106,672 KB
testcase_59 AC 487 ms
197,048 KB
testcase_60 AC 83 ms
71,832 KB
testcase_61 WA -
testcase_62 AC 85 ms
71,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
sys.setrecursionlimit(200000)


n, m = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
q = int(input())
a = [int(input()) for i in range(q)]

tree = [[] for i in range(n)]
for i in range(m):
    tree[info[i][0] - 1].append(info[i][1] - 1)
    tree[info[i][1] - 1].append(info[i][0] - 1)

def bfs(a):
    visited = [False]*n
    cnt = 0
    q = deque([])
    q.append([0, a])
    visited[a] = True
    while q:
        times, pos = q.popleft()
        for next_pos in tree[pos]:
            if not visited[next_pos]:
                visited[next_pos] = True
                cnt += 1
                q.append([times + 1, next_pos])
    if times == 0 and times == 1:
        day = 0
    else:
        day = (times-1).bit_length()
    return cnt, day


for i in range(q):
    ans1, ans2 = bfs(a[i] - 1)
    print(ans1, ans2)
0