結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
10,880 KB
testcase_01 AC 32 ms
11,008 KB
testcase_02 AC 30 ms
11,008 KB
testcase_03 AC 29 ms
11,008 KB
testcase_04 AC 28 ms
10,880 KB
testcase_05 AC 29 ms
10,880 KB
testcase_06 AC 30 ms
10,880 KB
testcase_07 AC 29 ms
10,880 KB
testcase_08 AC 28 ms
10,880 KB
testcase_09 AC 29 ms
11,008 KB
testcase_10 AC 29 ms
10,880 KB
testcase_11 AC 28 ms
11,008 KB
testcase_12 AC 32 ms
11,008 KB
testcase_13 AC 33 ms
11,136 KB
testcase_14 AC 34 ms
11,008 KB
testcase_15 AC 30 ms
11,008 KB
testcase_16 AC 32 ms
11,136 KB
testcase_17 AC 34 ms
11,008 KB
testcase_18 AC 33 ms
11,136 KB
testcase_19 AC 33 ms
11,008 KB
testcase_20 AC 35 ms
11,008 KB
testcase_21 AC 32 ms
11,008 KB
testcase_22 AC 33 ms
11,008 KB
testcase_23 AC 34 ms
11,008 KB
testcase_24 AC 33 ms
11,008 KB
testcase_25 AC 34 ms
11,136 KB
testcase_26 AC 34 ms
11,136 KB
testcase_27 AC 998 ms
32,124 KB
testcase_28 AC 977 ms
31,700 KB
testcase_29 AC 991 ms
32,456 KB
testcase_30 AC 1,017 ms
32,360 KB
testcase_31 AC 994 ms
31,888 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)
y = [0] * n
s = [0] * n
for i in range(n):
    y[i] = t.find(i)
    s[y[i]] += 1
for i in range(n):
    print(s[y[i]])

0