結果
問題 | No.1170 Never Want to Walk |
ユーザー |
![]() |
提出日時 | 2020-08-14 22:42:57 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 990 bytes |
コンパイル時間 | 204 ms |
コンパイル使用メモリ | 82,256 KB |
実行使用メモリ | 107,824 KB |
最終ジャッジ日時 | 2024-10-10 16:04:28 |
合計ジャッジ時間 | 8,917 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 30 TLE * 1 -- * 6 |
ソースコード
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)