結果

問題 No.1170 Never Want to Walk
ユーザー trineutrontrineutron
提出日時 2020-08-15 15:40:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 869 bytes
コンパイル時間 283 ms
コンパイル使用メモリ 13,056 KB
実行使用メモリ 32,908 KB
最終ジャッジ日時 2024-04-19 01:14:59
合計ジャッジ時間 11,279 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 32 ms
10,880 KB
testcase_02 AC 31 ms
11,008 KB
testcase_03 AC 31 ms
10,880 KB
testcase_04 AC 30 ms
10,880 KB
testcase_05 AC 31 ms
10,752 KB
testcase_06 AC 30 ms
11,008 KB
testcase_07 AC 30 ms
10,880 KB
testcase_08 AC 31 ms
10,880 KB
testcase_09 AC 31 ms
10,880 KB
testcase_10 AC 31 ms
10,880 KB
testcase_11 AC 31 ms
11,008 KB
testcase_12 AC 34 ms
10,880 KB
testcase_13 AC 36 ms
10,880 KB
testcase_14 AC 36 ms
10,880 KB
testcase_15 AC 36 ms
10,880 KB
testcase_16 AC 35 ms
10,880 KB
testcase_17 AC 36 ms
11,008 KB
testcase_18 AC 34 ms
10,880 KB
testcase_19 AC 35 ms
10,880 KB
testcase_20 AC 37 ms
10,880 KB
testcase_21 AC 35 ms
10,880 KB
testcase_22 AC 36 ms
11,008 KB
testcase_23 AC 36 ms
10,880 KB
testcase_24 AC 36 ms
10,752 KB
testcase_25 AC 36 ms
10,880 KB
testcase_26 AC 36 ms
11,136 KB
testcase_27 AC 1,037 ms
31,992 KB
testcase_28 AC 1,042 ms
31,560 KB
testcase_29 AC 1,037 ms
32,444 KB
testcase_30 AC 1,095 ms
32,344 KB
testcase_31 AC 1,042 ms
31,752 KB
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

class UnionFind:
    par = []
    
    def __init__(self, n):
        self.par = [i for i in range(n)]
    
    def find(self, n):
        if self.par[n] == n:
            return n
        p = self.find(self.par[n])
        self.par[n] = p
        return p
    
    def merge(self, m, n):
        m = self.find(m)
        n = self.find(n)
        self.par[m] = n

n, a, b = map(int, input().split())
x = list(map(int, input().split()))
v = [0] * (n + 1)
l = 0
r = 0
t = UnionFind(n)
for i in range(n):
    while l < n and x[l] < x[i] + a:
        l += 1
    while r < n and x[r] <= x[i] + b:
        r += 1
    if l == r:
        continue
    v[l] += 1
    v[r - 1] -= 1
    t.merge(i, l)
for i in range(n):
    v[i + 1] += v[i]
    if v[i] > 0:
        t.merge(i, i + 1)
s = [0] * n
for i in range(n):
    s[t.find(i)] += 1
for i in range(n):
    print(s[t.find(i)])

0