結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
57,984 KB
testcase_01 AC 37 ms
52,480 KB
testcase_02 AC 36 ms
52,352 KB
testcase_03 AC 36 ms
52,736 KB
testcase_04 AC 38 ms
52,352 KB
testcase_05 AC 37 ms
52,608 KB
testcase_06 AC 36 ms
52,224 KB
testcase_07 AC 36 ms
52,608 KB
testcase_08 AC 37 ms
52,864 KB
testcase_09 AC 36 ms
52,480 KB
testcase_10 AC 37 ms
52,224 KB
testcase_11 AC 38 ms
52,992 KB
testcase_12 AC 56 ms
67,584 KB
testcase_13 AC 60 ms
70,784 KB
testcase_14 AC 64 ms
70,528 KB
testcase_15 AC 58 ms
66,944 KB
testcase_16 AC 61 ms
68,608 KB
testcase_17 AC 68 ms
73,216 KB
testcase_18 AC 58 ms
66,816 KB
testcase_19 AC 61 ms
68,224 KB
testcase_20 AC 77 ms
76,416 KB
testcase_21 AC 62 ms
67,840 KB
testcase_22 AC 75 ms
72,960 KB
testcase_23 AC 75 ms
74,368 KB
testcase_24 AC 71 ms
73,088 KB
testcase_25 AC 70 ms
72,704 KB
testcase_26 AC 73 ms
74,540 KB
testcase_27 AC 278 ms
101,728 KB
testcase_28 AC 259 ms
108,572 KB
testcase_29 AC 293 ms
101,760 KB
testcase_30 AC 278 ms
101,560 KB
testcase_31 AC 279 ms
101,456 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()))
ue=0
uf=UnionFind(n)
from bisect import bisect_left as bl,bisect_right as br
for i,x in enumerate(l): 
    for j in range(bl(l,x-b),br(l,x-a)):uf.unite(i,j)    
for i in range(n):print(uf.size(i))
0