結果
問題 | No.1170 Never Want to Walk |
ユーザー | Salmonize |
提出日時 | 2020-08-14 21:47:17 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,972 bytes |
コンパイル時間 | 300 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 32,836 KB |
最終ジャッジ日時 | 2024-10-10 14:54:42 |
合計ジャッジ時間 | 14,969 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
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 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
ソースコード
import sys readline = sys.stdin.readline readall = sys.stdin.read ns = lambda: readline().rstrip() ni = lambda: int(readline().rstrip()) nm = lambda: map(int, readline().split()) nl = lambda: list(map(int, readline().split())) prn = lambda x: print(*x, sep='\n') class UnionFind: def __init__(self, n): self.ps = [-1] * (n + 1) def find(self, x): if self.ps[x] < 0: return x else: self.ps[x] = self.find(self.ps[x]) return self.ps[x] def unite(self, x, y): x = self.find(x) y = self.find(y) if x == y: return False if self.ps[x] > self.ps[y]: x, y = y, x self.ps[x] += self.ps[y] self.ps[y] = x return True def same(self, x, y): return self.find(x) == self.find(y) def size(self, x): x = self.find(x) return -self.ps[x] def solve(): n, a, b = nm() l = nl() uf = UnionFind(n) cur = -1 lef, rig = 0, 0 for i in range(n): while lef < n and l[lef] - l[i] < a: lef += 1 while rig + 1 < n and l[rig + 1] - l[i] <= b: rig += 1 for j in range(max(cur, lef), rig): uf.unite(j, j+1) # print('a', j, j+1) cur = rig if lef <= rig: uf.unite(i, lef) # print('b', i, lef) uf.unite(i, rig) # print('b', i, rig) print(i, lef, rig) # cur = n # lef, rig = n-1, n-1 # for i in range(n-1, -1, -1): # while rig >= 0 and l[i] - l[rig] < a: # rig -= 1 # while lef > 0 and l[i] - l[lef-1] <= b: # lef -= 1 # for j in range(min(cur, rig), lef): # uf.unite(j, j-1) # cur = lef # if rig >= 0: # uf.unite(i, lef) # uf.unite(i, rig) # print(i, lef, rig) for i in range(n): print(uf.size(i)) return solve()