結果
問題 | No.1170 Never Want to Walk |
ユーザー | arahi10 |
提出日時 | 2020-08-14 22:00:04 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,592 bytes |
コンパイル時間 | 475 ms |
コンパイル使用メモリ | 82,124 KB |
実行使用メモリ | 108,728 KB |
最終ジャッジ日時 | 2024-10-10 15:13:44 |
合計ジャッジ時間 | 9,028 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
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) print(i,left,right,bl(l,x-b),br(l,x-a)) for i in range(n):print(-uf._parents[uf.find(i)])