結果
| 問題 | No.1170 Never Want to Walk |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-12-30 18:43:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 804 bytes |
| コンパイル時間 | 307 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 159,784 KB |
| 最終ジャッジ日時 | 2024-12-30 18:44:29 |
| 合計ジャッジ時間 | 30,319 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 30 TLE * 7 |
ソースコード
import bisect
from collections import deque
N,A,B=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
ne=[-1]*N
def root(N):
if ne[N]<0:
return N
else:
ne[N]=root(ne[N])
return ne[N]
def merge(x,y):
x,y=root(x),root(y)
if ne[x]>ne[y]:
x,y=y,x
ne[x]+=ne[y]
ne[y]=x
def same(x,y):
return root(x)==root(y)
q=deque()
for i in range(N):
eru=bisect.bisect_left(x,x[i]+A)
aru=bisect.bisect_right(x,x[i]+B)
for v in range(eru,aru):
if same(i,v):
continue
merge(i,v)
q.append(v)
while q:
n=q.popleft()
eru=bisect.bisect_left(x,x[n]+A)
aru=bisect.bisect_right(x,x[n]+B)
for v in range(eru,aru):
if same(n,v):
continue
merge(n,v)
q.append(v)
for i in range(N):
print(-ne[root(i)])