結果

問題 No.1170 Never Want to Walk
ユーザー sangonanasangonana
提出日時 2020-08-15 18:49:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 687 bytes
コンパイル時間 82 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 33,092 KB
最終ジャッジ日時 2024-04-19 02:49:54
合計ジャッジ時間 12,109 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
10,880 KB
testcase_01 AC 30 ms
11,008 KB
testcase_02 WA -
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 32 ms
10,880 KB
testcase_05 AC 28 ms
11,008 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 29 ms
10,880 KB
testcase_10 AC 30 ms
11,008 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,a,b=map(int,input().split())
x=list(map(int,input().split()))
def root(x):
	if x!=parent[x]:
		x=parent[x]
	return x
def unite(x,y):
	rx=root(x)
	ry=root(y)
	if rank[rx]<rank[ry]:
		parent[rx]=ry
		size[ry]+=size[rx]
	else:
		parent[ry]=rx
		size[rx]+=size[ry]
		if rank[rx]==rank[ry]:
			rank[rx]+=1
parent=list(range(n))
rank=[1]*n
size=[1]*n
from bisect import bisect_left as BL
from bisect import bisect_right as BR
node=[0]*(n+1)
for i in range(n):
	l=BL(x,x[i]+a)
	r=BR(x,x[i]+b)
	if l<n and l!=r:
		unite(i,l)
	if r-l>=2:
		node[l]+=1
		node[r-1]-=1
for i in range(n):
	node[i+1]+=node[i]
for i in range(n):
	if node[i]>0:
		unite(i,i+1)
for i in range(n):
	print(size[root(i)])
0