結果
問題 | No.1170 Never Want to Walk |
ユーザー | anagohirame |
提出日時 | 2020-08-14 22:21:31 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 561 ms / 2,000 ms |
コード長 | 1,222 bytes |
コンパイル時間 | 391 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 104,584 KB |
最終ジャッジ日時 | 2024-04-18 22:13:15 |
合計ジャッジ時間 | 9,502 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,480 KB |
testcase_01 | AC | 43 ms
52,224 KB |
testcase_02 | AC | 45 ms
52,608 KB |
testcase_03 | AC | 45 ms
52,608 KB |
testcase_04 | AC | 45 ms
52,480 KB |
testcase_05 | AC | 45 ms
52,736 KB |
testcase_06 | AC | 46 ms
52,736 KB |
testcase_07 | AC | 46 ms
52,224 KB |
testcase_08 | AC | 45 ms
52,352 KB |
testcase_09 | AC | 46 ms
52,352 KB |
testcase_10 | AC | 45 ms
52,608 KB |
testcase_11 | AC | 46 ms
52,480 KB |
testcase_12 | AC | 75 ms
68,096 KB |
testcase_13 | AC | 80 ms
70,272 KB |
testcase_14 | AC | 82 ms
71,040 KB |
testcase_15 | AC | 75 ms
67,712 KB |
testcase_16 | AC | 77 ms
68,992 KB |
testcase_17 | AC | 82 ms
69,888 KB |
testcase_18 | AC | 70 ms
66,688 KB |
testcase_19 | AC | 75 ms
69,248 KB |
testcase_20 | AC | 82 ms
71,808 KB |
testcase_21 | AC | 72 ms
67,328 KB |
testcase_22 | AC | 83 ms
71,424 KB |
testcase_23 | AC | 89 ms
73,984 KB |
testcase_24 | AC | 81 ms
72,320 KB |
testcase_25 | AC | 81 ms
71,296 KB |
testcase_26 | AC | 84 ms
72,192 KB |
testcase_27 | AC | 503 ms
103,396 KB |
testcase_28 | AC | 491 ms
103,460 KB |
testcase_29 | AC | 534 ms
104,584 KB |
testcase_30 | AC | 561 ms
103,644 KB |
testcase_31 | AC | 495 ms
103,564 KB |
testcase_32 | AC | 393 ms
103,444 KB |
testcase_33 | AC | 428 ms
103,816 KB |
testcase_34 | AC | 429 ms
104,212 KB |
testcase_35 | AC | 427 ms
103,756 KB |
testcase_36 | AC | 391 ms
103,304 KB |
testcase_37 | AC | 412 ms
103,208 KB |
testcase_38 | AC | 392 ms
103,788 KB |
ソースコード
from bisect import bisect, bisect_left import sys def input(): return sys.stdin.readline()[:-1] class UnionFind(): def __init__(self, size): self.table = [-1 for _ in range(size)] self.size = [1 for _ in range(size)] def find(self, x): while self.table[x] >= 0: if self.table[self.table[x]] >= 0: self.table[x] = self.table[self.table[x]] x = self.table[x] return x def unite(self, x, y): s1 = self.find(x) s2 = self.find(y) if s1 == s2: return False else: if self.table[s1] > self.table[s2]: self.table[s2] = s1 self.table[s1] -= 1 self.size[s1] += self.size[s2] self.size[s2] = 0 else: self.table[s1] = s2 self.table[s2] -= 1 self.size[s2] += self.size[s1] self.size[s1] = 0 return True def get_size(self, x): return self.size[self.find(x)] n, a, b = map(int, input().split()) x = list(map(int, input().split())) uf = UnionFind(n) rm = -1 for i in range(n): l = bisect_left(x, x[i]+a) r = bisect(x, x[i]+b) #print(l, r) if l == r or l == n: continue uf.unite(i, l) for j in range(max(l, rm), r-1): if uf.find(j) != uf.find(j+1): uf.unite(j, j+1) else: break rm = r-1 print(*[uf.get_size(i) for i in range(n)], sep="\n")