結果

問題 No.812 Change of Class
ユーザー titiatitia
提出日時 2019-04-12 22:11:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,313 ms / 4,000 ms
コード長 887 bytes
コンパイル時間 372 ms
コンパイル使用メモリ 86,872 KB
実行使用メモリ 121,568 KB
最終ジャッジ日時 2023-09-03 12:48:16
合計ジャッジ時間 31,629 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 839 ms
115,076 KB
testcase_01 AC 251 ms
83,560 KB
testcase_02 AC 528 ms
98,560 KB
testcase_03 AC 986 ms
121,568 KB
testcase_04 AC 898 ms
116,544 KB
testcase_05 AC 1,313 ms
108,132 KB
testcase_06 AC 738 ms
104,236 KB
testcase_07 AC 123 ms
86,416 KB
testcase_08 AC 115 ms
77,112 KB
testcase_09 AC 1,141 ms
112,152 KB
testcase_10 AC 1,204 ms
110,464 KB
testcase_11 AC 165 ms
104,292 KB
testcase_12 AC 558 ms
108,972 KB
testcase_13 AC 112 ms
73,296 KB
testcase_14 AC 109 ms
73,140 KB
testcase_15 AC 567 ms
99,676 KB
testcase_16 AC 163 ms
80,504 KB
testcase_17 AC 686 ms
101,164 KB
testcase_18 AC 542 ms
96,312 KB
testcase_19 AC 446 ms
99,236 KB
testcase_20 AC 1,056 ms
108,160 KB
testcase_21 AC 353 ms
94,376 KB
testcase_22 AC 260 ms
87,752 KB
testcase_23 AC 166 ms
80,548 KB
testcase_24 AC 171 ms
81,000 KB
testcase_25 AC 248 ms
87,284 KB
testcase_26 AC 750 ms
104,668 KB
testcase_27 AC 948 ms
102,620 KB
testcase_28 AC 497 ms
99,088 KB
testcase_29 AC 230 ms
82,288 KB
testcase_30 AC 565 ms
100,360 KB
testcase_31 AC 575 ms
97,196 KB
testcase_32 AC 282 ms
89,252 KB
testcase_33 AC 711 ms
105,040 KB
testcase_34 AC 170 ms
80,620 KB
testcase_35 AC 225 ms
86,896 KB
testcase_36 AC 179 ms
80,948 KB
testcase_37 AC 354 ms
90,668 KB
testcase_38 AC 139 ms
89,360 KB
testcase_39 AC 394 ms
90,144 KB
testcase_40 AC 198 ms
81,980 KB
testcase_41 AC 134 ms
88,328 KB
testcase_42 AC 836 ms
98,864 KB
testcase_43 AC 225 ms
97,524 KB
testcase_44 AC 452 ms
93,772 KB
testcase_45 AC 175 ms
80,912 KB
testcase_46 AC 223 ms
98,852 KB
testcase_47 AC 557 ms
94,572 KB
testcase_48 AC 524 ms
98,024 KB
testcase_49 AC 236 ms
83,392 KB
testcase_50 AC 137 ms
79,440 KB
testcase_51 AC 226 ms
89,712 KB
testcase_52 AC 354 ms
97,336 KB
testcase_53 AC 208 ms
81,988 KB
testcase_54 AC 184 ms
81,728 KB
testcase_55 AC 321 ms
105,684 KB
testcase_56 AC 360 ms
113,160 KB
testcase_57 AC 376 ms
116,296 KB
testcase_58 AC 257 ms
95,964 KB
testcase_59 AC 406 ms
120,740 KB
testcase_60 AC 110 ms
73,332 KB
testcase_61 AC 109 ms
73,448 KB
testcase_62 AC 109 ms
73,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import copy
from collections import deque
input = sys.stdin.readline

N,M=map(int,input().split())

FRIEND=[list(map(int,input().split())) for i in range(M)]
q=int(input())
Q=[int(input()) for i in range(q)]

EDGELIST=[[] for i in range(N+1)]

for x,y in FRIEND:
    EDGELIST[x].append(y)
    EDGELIST[y].append(x)


for query in Q:
    NQUE=deque()
    check=[0]*(N+1)

    check[query]=1
    for n in EDGELIST[query]:
        check[n]=1
        NQUE.append(n)

    DAY=0

    while NQUE:
        QUE=copy.copy(NQUE)
        NQUE=deque()
        dayflag=0

        while QUE:
            x=QUE.pop()

            for to in EDGELIST[x]:
                if check[to]==1:
                    continue
                NQUE.append(to)
                dayflag=1
                check[to]=1

        if dayflag==1:
            DAY+=1


    print(check.count(1)-1,DAY.bit_length())

0