結果

問題 No.1170 Never Want to Walk
ユーザー kohei2019kohei2019
提出日時 2022-07-19 22:36:49
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 933 bytes
コンパイル時間 169 ms
コンパイル使用メモリ 82,228 KB
実行使用メモリ 111,032 KB
最終ジャッジ日時 2024-07-02 02:34:08
合計ジャッジ時間 8,889 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import collections
N,A,B = map(int,input().split())
lsx = list(map(int,input().split()))

used = [-1]*(N)
ap = [False]*(N)
for i in range(N):
    if used[i] != -1:
        continue
    d = collections.deque([i])
    while d:
        now = d.popleft()
        if used[now] != -1:
            continue
        used[now] = i
        indl = bisect.bisect_left(lsx, lsx[now]-B)
        indr = bisect.bisect_right(lsx, lsx[now]-A)
        for nex in range(indl,indr):
            if used[nex] != -1 or ap[nex]:
                continue
            ap[nex] = True
            d.append(nex)
        indl = bisect.bisect_left(lsx, lsx[now]+A)
        indr = bisect.bisect_right(lsx, lsx[now]+B)
        for nex in range(indl,indr):
            if used[nex] != -1 or ap[nex]:
                continue
            ap[nex] = True
            d.append(nex)

cnt = collections.Counter(used)
for i in range(N):
    print(cnt[used[i]])
0