結果

問題 No.812 Change of Class
ユーザー persimmon-persimmonpersimmon-persimmon
提出日時 2021-06-17 13:49:16
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,428 ms / 4,000 ms
コード長 925 bytes
コンパイル時間 289 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 197,304 KB
最終ジャッジ日時 2023-08-30 21:20:44
合計ジャッジ時間 36,787 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 580 ms
172,836 KB
testcase_01 AC 207 ms
90,276 KB
testcase_02 AC 380 ms
128,120 KB
testcase_03 AC 666 ms
191,536 KB
testcase_04 AC 600 ms
178,504 KB
testcase_05 AC 1,428 ms
171,748 KB
testcase_06 AC 1,021 ms
155,020 KB
testcase_07 AC 95 ms
77,444 KB
testcase_08 AC 94 ms
76,728 KB
testcase_09 AC 1,174 ms
171,520 KB
testcase_10 AC 1,283 ms
169,044 KB
testcase_11 AC 148 ms
86,304 KB
testcase_12 AC 839 ms
145,212 KB
testcase_13 AC 89 ms
71,652 KB
testcase_14 AC 89 ms
71,456 KB
testcase_15 AC 895 ms
151,980 KB
testcase_16 AC 176 ms
79,844 KB
testcase_17 AC 797 ms
149,192 KB
testcase_18 AC 574 ms
132,844 KB
testcase_19 AC 677 ms
142,040 KB
testcase_20 AC 1,290 ms
166,920 KB
testcase_21 AC 552 ms
125,592 KB
testcase_22 AC 313 ms
100,764 KB
testcase_23 AC 168 ms
79,412 KB
testcase_24 AC 176 ms
80,072 KB
testcase_25 AC 283 ms
98,924 KB
testcase_26 AC 1,130 ms
164,356 KB
testcase_27 AC 915 ms
149,232 KB
testcase_28 AC 630 ms
141,936 KB
testcase_29 AC 233 ms
87,764 KB
testcase_30 AC 838 ms
152,800 KB
testcase_31 AC 715 ms
139,532 KB
testcase_32 AC 357 ms
106,552 KB
testcase_33 AC 936 ms
155,652 KB
testcase_34 AC 172 ms
79,896 KB
testcase_35 AC 271 ms
99,984 KB
testcase_36 AC 192 ms
80,144 KB
testcase_37 AC 473 ms
125,212 KB
testcase_38 AC 124 ms
78,560 KB
testcase_39 AC 499 ms
122,512 KB
testcase_40 AC 215 ms
85,568 KB
testcase_41 AC 127 ms
79,988 KB
testcase_42 AC 1,024 ms
159,584 KB
testcase_43 AC 225 ms
94,124 KB
testcase_44 AC 714 ms
145,276 KB
testcase_45 AC 195 ms
80,460 KB
testcase_46 AC 217 ms
92,452 KB
testcase_47 AC 656 ms
148,412 KB
testcase_48 AC 701 ms
139,292 KB
testcase_49 AC 301 ms
98,116 KB
testcase_50 AC 131 ms
78,360 KB
testcase_51 AC 266 ms
98,916 KB
testcase_52 AC 379 ms
117,432 KB
testcase_53 AC 230 ms
87,808 KB
testcase_54 AC 221 ms
84,844 KB
testcase_55 AC 501 ms
163,840 KB
testcase_56 AC 565 ms
178,888 KB
testcase_57 AC 579 ms
178,636 KB
testcase_58 AC 368 ms
130,884 KB
testcase_59 AC 656 ms
197,304 KB
testcase_60 AC 88 ms
71,632 KB
testcase_61 AC 88 ms
71,536 KB
testcase_62 AC 90 ms
71,276 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m=map(int,input().split())
pq=[list(map(int,input().split())) for _ in range(m)]
q=int(input())
a=[int(input()) for _ in range(q)]
g=[[] for _ in range(n)]
for p,q in pq:
  p,q=p-1,q-1
  g[p].append(q)
  g[q].append(p)
from collections import deque
for v in a:
  v-=1
  todo=deque([v])
  d={}
  d[v]=0
  while todo:
    v=todo.popleft()
    for nv in g[v]:
      if nv not in d:
        d[nv]=d[v]+1
        todo.append(nv)
  x=d[v]
  for i in range(31):
    if x<=pow(2,i):
      print(len(d)-1,i)
      break

"""
スターグラフなら1日目で達成
長さLのパスグラフならlog(L)??
周長Lの閉路グラフなら
それぞれの連結成分で一番最後に友達になるペアを見つける
log(最長パス)かな?
1日目:距離2の頂点間に辺
2日目:距離3,4の頂点間に辺
3日目:距離5~8の頂点間に辺
4日目:距離9~16の頂点間に辺
5日目:距離17~32の頂点間に辺
"""
0