結果
問題 | No.1170 Never Want to Walk |
ユーザー | arahi10 |
提出日時 | 2020-08-14 22:00:47 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,548 bytes |
コンパイル時間 | 246 ms |
コンパイル使用メモリ | 82,324 KB |
実行使用メモリ | 108,700 KB |
最終ジャッジ日時 | 2024-10-10 15:15:12 |
合計ジャッジ時間 | 7,387 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
60,480 KB |
testcase_01 | AC | 38 ms
52,924 KB |
testcase_02 | AC | 40 ms
53,012 KB |
testcase_03 | AC | 39 ms
53,284 KB |
testcase_04 | AC | 40 ms
53,976 KB |
testcase_05 | AC | 40 ms
53,948 KB |
testcase_06 | AC | 39 ms
52,616 KB |
testcase_07 | AC | 38 ms
53,844 KB |
testcase_08 | AC | 38 ms
53,292 KB |
testcase_09 | AC | 38 ms
52,984 KB |
testcase_10 | AC | 38 ms
53,480 KB |
testcase_11 | AC | 37 ms
53,076 KB |
testcase_12 | AC | 51 ms
63,528 KB |
testcase_13 | AC | 57 ms
66,408 KB |
testcase_14 | AC | 57 ms
66,952 KB |
testcase_15 | AC | 52 ms
63,176 KB |
testcase_16 | AC | 53 ms
64,844 KB |
testcase_17 | AC | 59 ms
67,088 KB |
testcase_18 | AC | 52 ms
63,340 KB |
testcase_19 | AC | 53 ms
63,652 KB |
testcase_20 | AC | 61 ms
69,060 KB |
testcase_21 | AC | 52 ms
63,780 KB |
testcase_22 | AC | 67 ms
70,452 KB |
testcase_23 | AC | 63 ms
70,164 KB |
testcase_24 | AC | 66 ms
69,772 KB |
testcase_25 | AC | 67 ms
70,376 KB |
testcase_26 | AC | 67 ms
71,076 KB |
testcase_27 | AC | 185 ms
101,524 KB |
testcase_28 | AC | 165 ms
108,700 KB |
testcase_29 | AC | 202 ms
102,116 KB |
testcase_30 | AC | 183 ms
101,988 KB |
testcase_31 | AC | 193 ms
101,356 KB |
testcase_32 | TLE | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
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)])