結果

問題 No.812 Change of Class
ユーザー amyuamyu
提出日時 2019-04-13 01:35:59
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 3,179 ms / 4,000 ms
コード長 744 bytes
コンパイル時間 769 ms
コンパイル使用メモリ 10,732 KB
実行使用メモリ 40,128 KB
最終ジャッジ日時 2023-09-03 14:33:05
合計ジャッジ時間 71,742 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2,258 ms
33,684 KB
testcase_01 AC 339 ms
12,188 KB
testcase_02 AC 1,175 ms
21,904 KB
testcase_03 AC 2,547 ms
38,260 KB
testcase_04 AC 2,229 ms
34,292 KB
testcase_05 AC 3,179 ms
38,484 KB
testcase_06 AC 2,807 ms
35,672 KB
testcase_07 AC 24 ms
10,972 KB
testcase_08 AC 19 ms
9,164 KB
testcase_09 AC 2,759 ms
39,888 KB
testcase_10 AC 2,948 ms
40,128 KB
testcase_11 AC 130 ms
20,444 KB
testcase_12 AC 1,691 ms
35,696 KB
testcase_13 AC 17 ms
7,784 KB
testcase_14 AC 17 ms
7,776 KB
testcase_15 AC 2,004 ms
29,048 KB
testcase_16 AC 95 ms
9,852 KB
testcase_17 AC 1,755 ms
30,524 KB
testcase_18 AC 1,337 ms
24,620 KB
testcase_19 AC 1,492 ms
27,008 KB
testcase_20 AC 3,044 ms
39,420 KB
testcase_21 AC 1,209 ms
23,856 KB
testcase_22 AC 491 ms
15,548 KB
testcase_23 AC 76 ms
9,512 KB
testcase_24 AC 119 ms
10,480 KB
testcase_25 AC 359 ms
14,072 KB
testcase_26 AC 2,485 ms
34,456 KB
testcase_27 AC 2,123 ms
31,072 KB
testcase_28 AC 1,430 ms
26,828 KB
testcase_29 AC 261 ms
12,280 KB
testcase_30 AC 1,881 ms
30,004 KB
testcase_31 AC 1,621 ms
26,492 KB
testcase_32 AC 644 ms
17,532 KB
testcase_33 AC 1,969 ms
32,748 KB
testcase_34 AC 107 ms
10,188 KB
testcase_35 AC 324 ms
13,540 KB
testcase_36 AC 137 ms
10,316 KB
testcase_37 AC 951 ms
18,884 KB
testcase_38 AC 53 ms
13,052 KB
testcase_39 AC 986 ms
18,708 KB
testcase_40 AC 195 ms
11,624 KB
testcase_41 AC 39 ms
12,324 KB
testcase_42 AC 2,157 ms
28,832 KB
testcase_43 AC 254 ms
21,768 KB
testcase_44 AC 1,505 ms
22,852 KB
testcase_45 AC 139 ms
10,176 KB
testcase_46 AC 243 ms
20,772 KB
testcase_47 AC 1,543 ms
23,228 KB
testcase_48 AC 1,422 ms
26,144 KB
testcase_49 AC 365 ms
13,316 KB
testcase_50 AC 32 ms
8,476 KB
testcase_51 AC 324 ms
14,788 KB
testcase_52 AC 661 ms
23,280 KB
testcase_53 AC 234 ms
11,556 KB
testcase_54 AC 203 ms
11,352 KB
testcase_55 AC 1,179 ms
27,996 KB
testcase_56 AC 1,399 ms
30,964 KB
testcase_57 AC 1,468 ms
32,836 KB
testcase_58 AC 768 ms
21,172 KB
testcase_59 AC 1,697 ms
36,180 KB
testcase_60 AC 16 ms
7,820 KB
testcase_61 AC 16 ms
7,836 KB
testcase_62 AC 16 ms
7,788 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