結果

問題 No.317 辺の追加
ユーザー TawaraTawara
提出日時 2015-12-12 17:24:39
言語 PyPy2
(7.3.13)
結果
AC  
実行時間 520 ms / 2,000 ms
コード長 443 bytes
コンパイル時間 1,518 ms
コンパイル使用メモリ 77,396 KB
実行使用メモリ 99,816 KB
最終ジャッジ日時 2023-08-25 02:35:00
合計ジャッジ時間 17,818 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
77,960 KB
testcase_01 AC 77 ms
77,884 KB
testcase_02 AC 314 ms
85,304 KB
testcase_03 AC 294 ms
84,324 KB
testcase_04 AC 343 ms
87,732 KB
testcase_05 AC 280 ms
83,708 KB
testcase_06 AC 320 ms
84,096 KB
testcase_07 AC 194 ms
82,912 KB
testcase_08 AC 520 ms
90,356 KB
testcase_09 AC 324 ms
85,860 KB
testcase_10 AC 357 ms
85,112 KB
testcase_11 AC 262 ms
99,816 KB
testcase_12 AC 358 ms
85,060 KB
testcase_13 AC 289 ms
94,696 KB
testcase_14 AC 339 ms
85,064 KB
testcase_15 AC 357 ms
85,056 KB
testcase_16 AC 339 ms
87,104 KB
testcase_17 AC 349 ms
85,336 KB
testcase_18 AC 360 ms
85,776 KB
testcase_19 AC 371 ms
85,220 KB
testcase_20 AC 379 ms
87,732 KB
testcase_21 AC 187 ms
83,696 KB
testcase_22 AC 169 ms
83,784 KB
testcase_23 AC 173 ms
84,108 KB
testcase_24 AC 220 ms
84,128 KB
testcase_25 AC 199 ms
84,232 KB
testcase_26 AC 207 ms
83,952 KB
testcase_27 AC 188 ms
83,520 KB
testcase_28 AC 172 ms
84,324 KB
testcase_29 AC 140 ms
82,932 KB
testcase_30 AC 445 ms
84,800 KB
testcase_31 AC 360 ms
84,728 KB
testcase_32 AC 422 ms
84,972 KB
testcase_33 AC 362 ms
84,756 KB
testcase_34 AC 359 ms
84,848 KB
testcase_35 AC 369 ms
84,872 KB
testcase_36 AC 365 ms
84,792 KB
testcase_37 AC 366 ms
84,868 KB
testcase_38 AC 360 ms
84,736 KB
testcase_39 AC 363 ms
84,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict as D
I=int;f=lambda:map(I,raw_input().split());R=range;N,M=f();P=R(N+1)
def r(x):
	while x^P[x]:P[x]=x=P[P[x]]
	return x
Cc=D(I);Cn=D(I);A=[N]*(N+1);A[0]=0
for i in R(M):u,v=map(r,f());P[u]=v
for i in R(N):Cc[r(i+1)]+=1
for v in Cc.values():Cn[v]+=1
for v,n in Cn.items():
	m=1
	while n>0:
		m=min(m,n);w=v*m
		for j in R(N,w-1,-1):A[j]=min(A[j],A[j-w]+m)
		n-=m;m*=2
for i in R(N):print A[i+1]*(A[i+1]<N)-1
0