結果

問題 No.1170 Never Want to Walk
ユーザー sangonanasangonana
提出日時 2020-08-15 19:07:50
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 1,014 ms / 2,000 ms
コード長 714 bytes
コンパイル時間 84 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 32,964 KB
最終ジャッジ日時 2024-04-19 03:37:28
合計ジャッジ時間 14,438 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
10,880 KB
testcase_01 AC 35 ms
10,880 KB
testcase_02 AC 32 ms
11,008 KB
testcase_03 AC 32 ms
11,008 KB
testcase_04 AC 35 ms
11,008 KB
testcase_05 AC 31 ms
11,008 KB
testcase_06 AC 32 ms
11,008 KB
testcase_07 AC 31 ms
10,880 KB
testcase_08 AC 34 ms
11,008 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 31 ms
10,880 KB
testcase_11 AC 31 ms
10,880 KB
testcase_12 AC 34 ms
11,008 KB
testcase_13 AC 35 ms
11,008 KB
testcase_14 AC 36 ms
11,136 KB
testcase_15 AC 35 ms
11,136 KB
testcase_16 AC 35 ms
11,136 KB
testcase_17 AC 35 ms
11,008 KB
testcase_18 AC 34 ms
11,136 KB
testcase_19 AC 34 ms
11,136 KB
testcase_20 AC 35 ms
11,136 KB
testcase_21 AC 35 ms
11,136 KB
testcase_22 AC 36 ms
11,136 KB
testcase_23 AC 36 ms
11,136 KB
testcase_24 AC 35 ms
11,008 KB
testcase_25 AC 35 ms
11,136 KB
testcase_26 AC 35 ms
11,008 KB
testcase_27 AC 890 ms
31,980 KB
testcase_28 AC 878 ms
31,668 KB
testcase_29 AC 860 ms
32,432 KB
testcase_30 AC 893 ms
32,328 KB
testcase_31 AC 881 ms
32,084 KB
testcase_32 AC 950 ms
32,132 KB
testcase_33 AC 939 ms
31,704 KB
testcase_34 AC 1,014 ms
32,964 KB
testcase_35 AC 926 ms
32,732 KB
testcase_36 AC 950 ms
31,780 KB
testcase_37 AC 1,007 ms
32,152 KB
testcase_38 AC 978 ms
32,748 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,a,b=map(int,input().split())
x=list(map(int,input().split()))
def root(x):
	if x!=parent[x]:
		x=root(parent[x])
	return x
def unite(x,y):
	rx=root(x)
	ry=root(y)
	if rx==ry:
		return
	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