結果

問題 No.1170 Never Want to Walk
ユーザー titiatitia
提出日時 2020-08-14 22:42:57
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 990 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,144 KB
実行使用メモリ 107,692 KB
最終ジャッジ日時 2024-04-18 22:33:33
合計ジャッジ時間 9,130 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
58,112 KB
testcase_01 AC 40 ms
52,608 KB
testcase_02 AC 41 ms
52,608 KB
testcase_03 AC 39 ms
52,608 KB
testcase_04 AC 37 ms
52,608 KB
testcase_05 AC 39 ms
52,480 KB
testcase_06 AC 40 ms
52,352 KB
testcase_07 AC 37 ms
52,608 KB
testcase_08 AC 38 ms
52,864 KB
testcase_09 AC 39 ms
52,608 KB
testcase_10 AC 38 ms
52,352 KB
testcase_11 AC 39 ms
52,608 KB
testcase_12 AC 67 ms
68,992 KB
testcase_13 AC 90 ms
76,160 KB
testcase_14 AC 89 ms
76,160 KB
testcase_15 AC 70 ms
69,632 KB
testcase_16 AC 72 ms
70,656 KB
testcase_17 AC 95 ms
76,672 KB
testcase_18 AC 71 ms
67,968 KB
testcase_19 AC 74 ms
71,040 KB
testcase_20 AC 94 ms
76,544 KB
testcase_21 AC 73 ms
69,248 KB
testcase_22 AC 146 ms
76,288 KB
testcase_23 AC 113 ms
76,672 KB
testcase_24 AC 149 ms
76,288 KB
testcase_25 AC 153 ms
76,032 KB
testcase_26 AC 136 ms
76,928 KB
testcase_27 AC 457 ms
103,088 KB
testcase_28 AC 464 ms
103,424 KB
testcase_29 AC 472 ms
103,908 KB
testcase_30 AC 468 ms
103,388 KB
testcase_31 AC 426 ms
103,268 KB
testcase_32 TLE -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.readline
import bisect

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

# UnionFind

Group = [i for i in range(N+1)] # グループ分け
Nodes = [1]*(N+1) # 各グループのノードの数

def find(x):
    while Group[x] != x:
        x=Group[x]
    return x

def Union(x,y):
    if find(x) != find(y):
        if Nodes[find(x)] < Nodes[find(y)]:
            
            Nodes[find(y)] += Nodes[find(x)]
            Nodes[find(x)] = 0
            Group[find(x)] = find(y)
            
        else:
            Nodes[find(x)] += Nodes[find(y)]
            Nodes[find(y)] = 0
            Group[find(y)] = find(x)

for i in range(N):
    s=bisect.bisect_left(X,X[i]+a)
    t=bisect.bisect_right(X,X[i]+b)

    for j in range(s,t):
        Union(i,j)

ALIST=[[] for i in range(N)]

for i in range(N):
    ALIST[find(i)].append(i)

ANS=[-1]*N

for i in range(N):
    for a in ALIST[i]:
        ANS[a]=len(ALIST[i])

for a in ANS:
    print(a)
0