結果

問題 No.1170 Never Want to Walk
ユーザー brthyyjpbrthyyjp
提出日時 2020-11-08 14:34:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 940 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 87,112 KB
実行使用メモリ 105,116 KB
最終ジャッジ日時 2023-09-29 21:12:13
合計ジャッジ時間 9,859 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,324 KB
testcase_01 AC 71 ms
71,332 KB
testcase_02 WA -
testcase_03 AC 70 ms
71,360 KB
testcase_04 WA -
testcase_05 AC 71 ms
71,608 KB
testcase_06 AC 71 ms
71,252 KB
testcase_07 AC 72 ms
71,260 KB
testcase_08 AC 71 ms
71,568 KB
testcase_09 AC 72 ms
71,336 KB
testcase_10 AC 72 ms
71,576 KB
testcase_11 AC 71 ms
71,360 KB
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 -
権限があれば一括ダウンロードができます

ソースコード

diff #

n, a, b = map(int, input().split())
X = list(map(int, input().split()))

def Find(x, par):
    if par[x] < 0:
        return x
    else:
        par[x] = Find(par[x], par)
        return par[x]

def Unite(x, y, par, rank):
    x = Find(x, par)
    y = Find(y, par)

    if x != y:
        if rank[x] < rank[y]:
            par[y] += par[x]
            par[x] = y
        else:
            par[x] += par[y]
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1

def Same(x, y, par):
    return Find(x, par) == Find(y, par)

def Size(x, par):
    return -par[Find(x, par)]

par = [-1]* n
rank = [0]*n

j = 0
import bisect
for i in range(n):
    x = X[i]
    l = bisect.bisect_left(X, x+a)
    r = bisect.bisect_right(X, x+b)
    for k in range(l, r):
        if k < j:
            break
        Unite(i, k, par, rank)
    j = r-1
ans = [0]*n
for i in range(n):
    ans[i] = Size(i, par)
print(*ans, sep='\n')
0