結果
問題 | No.1170 Never Want to Walk |
ユーザー | chineristAC |
提出日時 | 2020-08-14 21:47:45 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,384 bytes |
コンパイル時間 | 237 ms |
コンパイル使用メモリ | 82,560 KB |
実行使用メモリ | 108,608 KB |
最終ジャッジ日時 | 2024-04-18 21:29:13 |
合計ジャッジ時間 | 8,208 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
57,856 KB |
testcase_01 | AC | 39 ms
53,120 KB |
testcase_02 | AC | 40 ms
52,352 KB |
testcase_03 | AC | 36 ms
52,864 KB |
testcase_04 | AC | 37 ms
52,864 KB |
testcase_05 | AC | 37 ms
52,864 KB |
testcase_06 | AC | 46 ms
52,480 KB |
testcase_07 | AC | 38 ms
52,608 KB |
testcase_08 | AC | 38 ms
52,336 KB |
testcase_09 | AC | 38 ms
52,352 KB |
testcase_10 | AC | 39 ms
52,352 KB |
testcase_11 | AC | 36 ms
52,992 KB |
testcase_12 | AC | 59 ms
67,200 KB |
testcase_13 | AC | 62 ms
69,760 KB |
testcase_14 | AC | 62 ms
70,188 KB |
testcase_15 | AC | 71 ms
67,456 KB |
testcase_16 | AC | 61 ms
67,968 KB |
testcase_17 | AC | 60 ms
70,912 KB |
testcase_18 | AC | 58 ms
66,816 KB |
testcase_19 | AC | 59 ms
68,224 KB |
testcase_20 | AC | 65 ms
72,832 KB |
testcase_21 | AC | 58 ms
67,456 KB |
testcase_22 | AC | 68 ms
71,936 KB |
testcase_23 | AC | 69 ms
72,704 KB |
testcase_24 | AC | 73 ms
72,976 KB |
testcase_25 | AC | 66 ms
71,680 KB |
testcase_26 | AC | 68 ms
74,172 KB |
testcase_27 | AC | 435 ms
103,108 KB |
testcase_28 | AC | 343 ms
103,168 KB |
testcase_29 | AC | 427 ms
103,784 KB |
testcase_30 | AC | 350 ms
104,044 KB |
testcase_31 | AC | 371 ms
103,136 KB |
testcase_32 | TLE | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
class UnionFindVerSize(): def __init__(self, N): self._parent = [n for n in range(0, N)] self._size = [1] * N def find_root(self, x): if self._parent[x] == x: return x self._parent[x] = self.find_root(self._parent[x]) return self._parent[x] def unite(self, x, y): gx = self.find_root(x) gy = self.find_root(y) if gx == gy: return if self._size[gx] < self._size[gy]: self._parent[gx] = gy self._size[gy] += self._size[gx] else: self._parent[gy] = gx self._size[gx] += self._size[gy] def get_size(self, x): return self._size[self.find_root(x)] def is_same_group(self, x, y): return self.find_root(x) == self.find_root(y) def calc_group_num(self): N = len(self._parent) ans = 0 for i in range(N): if self.find_root(i) == i: ans += 1 return ans def range_unite(self,l,r): for i in range(l,r): self.unite(i,i+1) import bisect N,A,B=map(int,input().split()) x=list(map(int,input().split())) uf=UnionFindVerSize(N) for i in range(N): idL=bisect.bisect_left(x,x[i]+A) idR=bisect.bisect_right(x,x[i]+B)-1 if idL<=idR: uf.unite(i,idL) uf.range_unite(idL,idR) for i in range(N): print(uf.get_size(i))