結果
問題 | No.1170 Never Want to Walk |
ユーザー | とりゐ |
提出日時 | 2022-04-19 18:59:30 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 418 ms / 2,000 ms |
コード長 | 1,321 bytes |
コンパイル時間 | 432 ms |
コンパイル使用メモリ | 87,052 KB |
実行使用メモリ | 112,872 KB |
最終ジャッジ日時 | 2023-08-30 17:17:04 |
合計ジャッジ時間 | 12,696 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 89 ms
71,656 KB |
testcase_01 | AC | 90 ms
71,840 KB |
testcase_02 | AC | 90 ms
71,432 KB |
testcase_03 | AC | 89 ms
71,380 KB |
testcase_04 | AC | 88 ms
71,696 KB |
testcase_05 | AC | 86 ms
71,584 KB |
testcase_06 | AC | 88 ms
71,856 KB |
testcase_07 | AC | 86 ms
71,748 KB |
testcase_08 | AC | 85 ms
71,828 KB |
testcase_09 | AC | 86 ms
71,808 KB |
testcase_10 | AC | 87 ms
71,692 KB |
testcase_11 | AC | 89 ms
71,780 KB |
testcase_12 | AC | 108 ms
76,780 KB |
testcase_13 | AC | 110 ms
76,936 KB |
testcase_14 | AC | 109 ms
76,756 KB |
testcase_15 | AC | 107 ms
76,784 KB |
testcase_16 | AC | 111 ms
77,088 KB |
testcase_17 | AC | 110 ms
76,868 KB |
testcase_18 | AC | 106 ms
76,764 KB |
testcase_19 | AC | 112 ms
77,056 KB |
testcase_20 | AC | 111 ms
76,928 KB |
testcase_21 | AC | 106 ms
76,864 KB |
testcase_22 | AC | 109 ms
77,028 KB |
testcase_23 | AC | 110 ms
77,256 KB |
testcase_24 | AC | 111 ms
77,044 KB |
testcase_25 | AC | 113 ms
77,040 KB |
testcase_26 | AC | 114 ms
77,000 KB |
testcase_27 | AC | 401 ms
112,240 KB |
testcase_28 | AC | 391 ms
112,300 KB |
testcase_29 | AC | 418 ms
112,184 KB |
testcase_30 | AC | 399 ms
112,196 KB |
testcase_31 | AC | 404 ms
112,384 KB |
testcase_32 | AC | 399 ms
112,212 KB |
testcase_33 | AC | 408 ms
112,592 KB |
testcase_34 | AC | 397 ms
112,320 KB |
testcase_35 | AC | 413 ms
112,148 KB |
testcase_36 | AC | 371 ms
112,276 KB |
testcase_37 | AC | 384 ms
112,180 KB |
testcase_38 | AC | 394 ms
112,872 KB |
ソースコード
import bisect #UnionFind from collections import defaultdict class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): if self.parents[x] < 0: return x else: self.parents[x] = self.find(self.parents[x]) return self.parents[x] def union(self, x, y): x = self.find(x) y = self.find(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.find(x)] def same(self, x, y): return self.find(x) == self.find(y) def members(self, x): root = self.find(x) return [i for i in range(self.n) if self.find(i) == root] def roots(self): return [i for i, x in enumerate(self.parents) if x < 0] n,a,b=map(int,input().split()) x=list(map(int,input().split())) unite=[0]*n uf=UnionFind(n) for i in range(n): L=bisect.bisect_left(x,x[i]+a) R=bisect.bisect_left(x,x[i]+b+1) if L!=R: uf.union(i,L) unite[L]+=1 unite[R-1]-=1 for i in range(n-1): if i: unite[i]+=unite[i-1] if unite[i]: uf.union(i,i+1) for i in range(n): print(uf.size(i))