結果

問題 No.1170 Never Want to Walk
ユーザー arahi10arahi10
提出日時 2020-08-14 22:00:47
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 1,548 bytes
コンパイル時間 190 ms
コンパイル使用メモリ 82,560 KB
実行使用メモリ 108,640 KB
最終ジャッジ日時 2024-04-18 21:47:59
合計ジャッジ時間 7,048 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 43 ms
58,112 KB
testcase_01 AC 38 ms
52,608 KB
testcase_02 AC 37 ms
52,352 KB
testcase_03 AC 37 ms
52,480 KB
testcase_04 AC 36 ms
52,740 KB
testcase_05 AC 37 ms
52,224 KB
testcase_06 AC 37 ms
53,120 KB
testcase_07 AC 37 ms
52,992 KB
testcase_08 AC 38 ms
52,992 KB
testcase_09 AC 37 ms
52,608 KB
testcase_10 AC 37 ms
52,352 KB
testcase_11 AC 36 ms
52,992 KB
testcase_12 AC 50 ms
62,080 KB
testcase_13 AC 55 ms
65,664 KB
testcase_14 AC 59 ms
65,792 KB
testcase_15 AC 55 ms
62,592 KB
testcase_16 AC 56 ms
63,232 KB
testcase_17 AC 59 ms
66,816 KB
testcase_18 AC 51 ms
62,720 KB
testcase_19 AC 50 ms
63,104 KB
testcase_20 AC 60 ms
68,096 KB
testcase_21 AC 50 ms
63,232 KB
testcase_22 AC 66 ms
69,888 KB
testcase_23 AC 63 ms
68,736 KB
testcase_24 AC 66 ms
68,480 KB
testcase_25 AC 67 ms
68,992 KB
testcase_26 AC 62 ms
69,504 KB
testcase_27 AC 180 ms
101,376 KB
testcase_28 AC 164 ms
108,640 KB
testcase_29 AC 194 ms
101,760 KB
testcase_30 AC 179 ms
101,904 KB
testcase_31 AC 185 ms
101,440 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,a,b=map(int,input().split())
class UnionFind:
    #def   -> foo=UnionFind(n,1)  <- 1-based index, default is 0
    #method -> foo.hoge(huga)
    __slots__ = ["_size", "_first_idx", "_parents"]
    def __init__(self, size: int, first_index: int = 0) -> None:
        self._size = size
        self._first_idx = first_index
        self._parents = [-1] * (size + first_index)
    def find(self, x: int) -> int:
        if self._parents[x] < 0:
            return x
        self._parents[x] = self.find(self._parents[x])
        return self._parents[x]
    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)
    def unite(self, x: int, y: int) -> bool:
        x, y = self.find(x), self.find(y)
        if x == y:
            return False
        if self._parents[x] > self._parents[y]:
            x, y = y, x
        self._parents[x] += self._parents[y]
        self._parents[y] = x
        return True
    def size(self, x: int) -> int:
        return -self._parents[self.find(x)]
    def group_count(self) ->int:
        return sum(1 for i in  self._parents if i<0)-self._first_idx
    def connected(self) ->bool:
        return self._parents[self.find(self._first_idx)]==-self._size
l=list(map(int,input().split()))
uf=UnionFind(n)
from bisect import bisect_left as bl,bisect_right as br
left,right=0,0
for i,x in enumerate(l):
    while left <n and  l[left]<x-b:left+=1
    while right <n and l[right]<=x-a:right+=1
    for j in range(left,right):uf.unite(i,j)
for i in range(n):print(-uf._parents[uf.find(i)])
0