結果

問題 No.812 Change of Class
ユーザー tpynerivertpyneriver
提出日時 2019-04-12 22:19:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,382 ms / 4,000 ms
コード長 791 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 86,720 KB
実行使用メモリ 184,236 KB
最終ジャッジ日時 2023-09-03 13:25:18
合計ジャッジ時間 33,205 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 497 ms
164,968 KB
testcase_01 AC 182 ms
89,236 KB
testcase_02 AC 333 ms
131,600 KB
testcase_03 AC 566 ms
183,024 KB
testcase_04 AC 518 ms
172,828 KB
testcase_05 AC 1,280 ms
167,292 KB
testcase_06 AC 966 ms
148,172 KB
testcase_07 AC 102 ms
85,404 KB
testcase_08 AC 97 ms
76,264 KB
testcase_09 AC 1,367 ms
159,756 KB
testcase_10 AC 1,382 ms
164,768 KB
testcase_11 AC 134 ms
101,912 KB
testcase_12 AC 804 ms
150,828 KB
testcase_13 AC 93 ms
71,484 KB
testcase_14 AC 93 ms
71,584 KB
testcase_15 AC 825 ms
152,404 KB
testcase_16 AC 154 ms
78,868 KB
testcase_17 AC 733 ms
144,204 KB
testcase_18 AC 590 ms
131,232 KB
testcase_19 AC 639 ms
147,408 KB
testcase_20 AC 1,243 ms
164,684 KB
testcase_21 AC 492 ms
126,024 KB
testcase_22 AC 300 ms
105,292 KB
testcase_23 AC 158 ms
78,720 KB
testcase_24 AC 166 ms
79,200 KB
testcase_25 AC 259 ms
96,764 KB
testcase_26 AC 1,085 ms
159,184 KB
testcase_27 AC 955 ms
146,656 KB
testcase_28 AC 663 ms
143,592 KB
testcase_29 AC 212 ms
86,708 KB
testcase_30 AC 896 ms
148,692 KB
testcase_31 AC 694 ms
136,456 KB
testcase_32 AC 335 ms
112,440 KB
testcase_33 AC 836 ms
153,288 KB
testcase_34 AC 156 ms
78,992 KB
testcase_35 AC 229 ms
96,860 KB
testcase_36 AC 168 ms
79,212 KB
testcase_37 AC 435 ms
121,360 KB
testcase_38 AC 115 ms
88,420 KB
testcase_39 AC 458 ms
123,280 KB
testcase_40 AC 201 ms
83,396 KB
testcase_41 AC 113 ms
86,960 KB
testcase_42 AC 941 ms
164,116 KB
testcase_43 AC 199 ms
102,384 KB
testcase_44 AC 629 ms
143,600 KB
testcase_45 AC 175 ms
79,156 KB
testcase_46 AC 187 ms
99,936 KB
testcase_47 AC 671 ms
144,756 KB
testcase_48 AC 596 ms
142,604 KB
testcase_49 AC 250 ms
94,776 KB
testcase_50 AC 121 ms
77,144 KB
testcase_51 AC 235 ms
97,156 KB
testcase_52 AC 339 ms
119,124 KB
testcase_53 AC 204 ms
87,208 KB
testcase_54 AC 203 ms
83,820 KB
testcase_55 AC 422 ms
162,344 KB
testcase_56 AC 475 ms
170,640 KB
testcase_57 AC 484 ms
169,624 KB
testcase_58 AC 310 ms
127,772 KB
testcase_59 AC 536 ms
184,236 KB
testcase_60 AC 94 ms
71,680 KB
testcase_61 AC 94 ms
71,404 KB
testcase_62 AC 93 ms
71,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque
import sys
input = sys.stdin.readline
N, M = map(int, input().split())
Edge = [[]for _ in range(N)]
for _ in range(M):
    a, b = map(int, input().split())
    Edge[a-1].append(b-1)
    Edge[b-1].append(a-1)
Q = int(input())
ans = [None]*Q
for q in range(Q):
    st = int(input())
    st -= 1
    Q = deque()
    Q.append(st)
    visited = set([st])
    dist = [-1]*N
    dist[st] = 0
    md = 0
    while Q:
        s = Q.pop()
        for v in Edge[s]:
            if v not in visited:
                visited.add(v)
                if dist[v] == -1:
                    dist[v] = dist[s] + 1
                    md = max(md, dist[v])
                Q.appendleft(v)
    ans[q] = (len(visited) - 1,(md-1).bit_length() if md else 0)
for a in ans:
    print(*a)
0