結果

問題 No.812 Change of Class
ユーザー amyuamyu
提出日時 2019-04-13 01:37:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,048 ms / 4,000 ms
コード長 744 bytes
コンパイル時間 665 ms
コンパイル使用メモリ 86,552 KB
実行使用メモリ 156,152 KB
最終ジャッジ日時 2023-09-03 14:47:10
合計ジャッジ時間 26,031 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 350 ms
105,432 KB
testcase_01 AC 158 ms
80,408 KB
testcase_02 AC 246 ms
91,296 KB
testcase_03 AC 398 ms
112,604 KB
testcase_04 AC 359 ms
107,808 KB
testcase_05 AC 1,048 ms
107,800 KB
testcase_06 AC 808 ms
103,120 KB
testcase_07 AC 76 ms
74,984 KB
testcase_08 AC 74 ms
74,576 KB
testcase_09 AC 975 ms
108,812 KB
testcase_10 AC 987 ms
108,724 KB
testcase_11 AC 132 ms
86,556 KB
testcase_12 AC 641 ms
103,668 KB
testcase_13 AC 76 ms
70,964 KB
testcase_14 AC 77 ms
70,780 KB
testcase_15 AC 661 ms
96,560 KB
testcase_16 AC 140 ms
77,820 KB
testcase_17 AC 514 ms
97,380 KB
testcase_18 AC 418 ms
92,808 KB
testcase_19 AC 491 ms
95,340 KB
testcase_20 AC 1,007 ms
107,540 KB
testcase_21 AC 482 ms
91,812 KB
testcase_22 AC 239 ms
85,204 KB
testcase_23 AC 138 ms
77,592 KB
testcase_24 AC 148 ms
78,640 KB
testcase_25 AC 199 ms
83,856 KB
testcase_26 AC 737 ms
102,456 KB
testcase_27 AC 709 ms
99,172 KB
testcase_28 AC 412 ms
94,708 KB
testcase_29 AC 177 ms
80,216 KB
testcase_30 AC 522 ms
97,028 KB
testcase_31 AC 420 ms
94,060 KB
testcase_32 AC 261 ms
86,408 KB
testcase_33 AC 610 ms
102,280 KB
testcase_34 AC 143 ms
78,476 KB
testcase_35 AC 194 ms
83,384 KB
testcase_36 AC 156 ms
78,908 KB
testcase_37 AC 355 ms
87,216 KB
testcase_38 AC 118 ms
80,884 KB
testcase_39 AC 328 ms
87,376 KB
testcase_40 AC 173 ms
79,976 KB
testcase_41 AC 114 ms
80,264 KB
testcase_42 AC 803 ms
97,068 KB
testcase_43 AC 206 ms
91,936 KB
testcase_44 AC 458 ms
90,984 KB
testcase_45 AC 155 ms
78,956 KB
testcase_46 AC 192 ms
95,728 KB
testcase_47 AC 467 ms
91,776 KB
testcase_48 AC 612 ms
94,632 KB
testcase_49 AC 207 ms
80,984 KB
testcase_50 AC 107 ms
76,352 KB
testcase_51 AC 195 ms
84,836 KB
testcase_52 AC 301 ms
93,788 KB
testcase_53 AC 173 ms
79,624 KB
testcase_54 AC 167 ms
79,272 KB
testcase_55 AC 315 ms
139,724 KB
testcase_56 AC 359 ms
144,744 KB
testcase_57 AC 357 ms
146,976 KB
testcase_58 AC 242 ms
118,588 KB
testcase_59 AC 414 ms
156,152 KB
testcase_60 AC 81 ms
70,728 KB
testcase_61 AC 73 ms
71,036 KB
testcase_62 AC 74 ms
71,032 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int, input().split())
pq = [list(map(int, input().split())) for i in range(m)] 
Q=int(input())
a = [int(input()) for i in range(Q)]
b=[[] for i in range(n+1)]
for i in pq:
    p=i[0]
    q=i[1]
    b[p].append(q)
    b[q].append(p)
for i in a:
    if(b[i]==[]):
        print(0,0)
        continue
    que=[i]
    check=[0 for i in range(n+1)]
    check[i]=1
    fri=0
    dif=-1
    while len(que)>0:
        tmpl=que.copy()
        que=[]
        for j in tmpl:
            for k in b[j]:
                if(check[k]==0):
                    que.append(k)
                    check[k]=1
                    fri+=1
        dif+=1
    day=0
    while dif!=1:
        dif=-(-dif//2)
        day+=1
    print(fri,day)
                    
0