結果

問題 No.1170 Never Want to Walk
ユーザー kohei2019
提出日時 2022-07-19 22:39:42
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,073 bytes
コンパイル時間 247 ms
コンパイル使用メモリ 81,948 KB
実行使用メモリ 109,440 KB
最終ジャッジ日時 2024-07-02 02:37:45
合計ジャッジ時間 8,805 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 30 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import collections

def main():
    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]])
main()
0