結果
問題 | No.1170 Never Want to Walk |
ユーザー | nishigake |
提出日時 | 2022-05-30 00:32:57 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,141 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 81,840 KB |
実行使用メモリ | 101,992 KB |
最終ジャッジ日時 | 2023-10-21 00:15:01 |
合計ジャッジ時間 | 7,238 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge9 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
53,616 KB |
testcase_01 | AC | 37 ms
53,616 KB |
testcase_02 | AC | 36 ms
53,616 KB |
testcase_03 | AC | 35 ms
53,616 KB |
testcase_04 | AC | 35 ms
53,616 KB |
testcase_05 | AC | 36 ms
53,616 KB |
testcase_06 | AC | 35 ms
53,616 KB |
testcase_07 | AC | 43 ms
53,616 KB |
testcase_08 | AC | 36 ms
53,616 KB |
testcase_09 | AC | 36 ms
53,616 KB |
testcase_10 | AC | 37 ms
53,616 KB |
testcase_11 | AC | 36 ms
53,616 KB |
testcase_12 | AC | 60 ms
70,080 KB |
testcase_13 | AC | 67 ms
72,160 KB |
testcase_14 | WA | - |
testcase_15 | AC | 71 ms
70,076 KB |
testcase_16 | AC | 62 ms
70,088 KB |
testcase_17 | AC | 71 ms
72,280 KB |
testcase_18 | AC | 60 ms
70,080 KB |
testcase_19 | AC | 62 ms
72,136 KB |
testcase_20 | AC | 65 ms
72,292 KB |
testcase_21 | AC | 60 ms
70,080 KB |
testcase_22 | AC | 65 ms
72,188 KB |
testcase_23 | AC | 67 ms
72,524 KB |
testcase_24 | AC | 66 ms
72,236 KB |
testcase_25 | AC | 65 ms
72,144 KB |
testcase_26 | AC | 65 ms
72,396 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | AC | 253 ms
101,808 KB |
testcase_33 | AC | 257 ms
101,052 KB |
testcase_34 | AC | 249 ms
101,520 KB |
testcase_35 | AC | 266 ms
101,728 KB |
testcase_36 | AC | 256 ms
101,252 KB |
testcase_37 | AC | 253 ms
101,040 KB |
testcase_38 | AC | 255 ms
101,588 KB |
ソースコード
from bisect import bisect_left, bisect_right class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def root(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.root(self.parents[x]) return self.parents[x] def unite(self, x, y): x = self.root(x) y = self.root(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.root(x)] def issame(self, x, y): return self.root(x) == self.root(y) N,A,B = list(map(int,input().split())) X = list(map(int,input().split())) uf = UnionFind(N) for i in range(N): l = bisect_left(X, X[i]-B) r = bisect_right(X, X[i]-A) for j in range(l, r): if uf.issame(i, j): break uf.unite(i, j) for j in range(r-1, l-1, -1): if uf.issame(i, j): break uf.unite(i, j) for i in range(N): print(uf.size(i))