結果
問題 | No.1170 Never Want to Walk |
ユーザー | Navier_Boltzmann |
提出日時 | 2022-10-05 03:59:45 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 3,012 bytes |
コンパイル時間 | 441 ms |
コンパイル使用メモリ | 13,184 KB |
実行使用メモリ | 569,132 KB |
最終ジャッジ日時 | 2024-12-30 23:59:33 |
合計ジャッジ時間 | 39,193 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 29 ms
18,212 KB |
testcase_01 | AC | 30 ms
80,728 KB |
testcase_02 | AC | 30 ms
18,340 KB |
testcase_03 | AC | 33 ms
18,084 KB |
testcase_04 | AC | 33 ms
18,212 KB |
testcase_05 | AC | 29 ms
73,256 KB |
testcase_06 | AC | 31 ms
18,212 KB |
testcase_07 | AC | 30 ms
81,640 KB |
testcase_08 | AC | 29 ms
18,208 KB |
testcase_09 | AC | 30 ms
78,848 KB |
testcase_10 | AC | 29 ms
17,956 KB |
testcase_11 | AC | 32 ms
485,480 KB |
testcase_12 | AC | 46 ms
18,084 KB |
testcase_13 | AC | 54 ms
419,820 KB |
testcase_14 | AC | 50 ms
18,468 KB |
testcase_15 | AC | 51 ms
469,312 KB |
testcase_16 | AC | 49 ms
18,464 KB |
testcase_17 | AC | 54 ms
488,124 KB |
testcase_18 | AC | 49 ms
18,212 KB |
testcase_19 | AC | 53 ms
484,812 KB |
testcase_20 | AC | 50 ms
18,464 KB |
testcase_21 | AC | 51 ms
488,088 KB |
testcase_22 | AC | 88 ms
21,792 KB |
testcase_23 | AC | 81 ms
14,336 KB |
testcase_24 | AC | 87 ms
14,848 KB |
testcase_25 | AC | 88 ms
15,104 KB |
testcase_26 | AC | 85 ms
14,592 KB |
testcase_27 | TLE | - |
testcase_28 | TLE | - |
testcase_29 | TLE | - |
testcase_30 | TLE | - |
testcase_31 | TLE | - |
testcase_32 | TLE | - |
testcase_33 | TLE | - |
testcase_34 | TLE | - |
testcase_35 | TLE | - |
testcase_36 | TLE | - |
testcase_37 | TLE | - |
testcase_38 | MLE | - |
ソースコード
# import pypyjit # pypyjit.set_param('max_unroll_recursion=-1') from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline N,A,B = map(int,input().split()) X = list(map(int,input().split())) INF = (1<<40) n = math.ceil(math.sqrt(N)) M = n**2 X = X + [INF]*(M - len(X)) e = [[] for _ in range(M+n)] for i in range(n): for j in range(n): e[M+i].append(n*i+j) for i in range(N): xi = X[i] l = N ng = i while l-ng>1: mid = (l+ng)//2 if X[mid]>=A+xi: l = mid else: ng = mid r = i ng = N while ng-r>1: mid = (ng+r)//2 if X[mid]<=xi+B: r = mid else: ng = mid r += 1 if l < r: L = (l+n-1)//n R = (r+n-1)//n if L==R: for j in range(l,r): e[i].append(j) else: for j in range(l,n*L): e[i].append(j) e[j].append(i) for j in range(M+L,M+R-1): e[i].append(j) e[j].append(i) for j in range(n*(R-1),r): e[i].append(j) e[j].append(i) ng = 0 l = 0 if xi - X[ng]>B: l = i while l-ng>1: mid = (ng+l)//2 if xi - X[mid]>B: ng = mid else: l = mid r = 0 ng = i+1 if xi-X[r]<A: continue while ng-r>1: mid = (ng+r)//2 if xi - X[mid] >= A: r = mid else: ng = mid r += 1 if l>=r: continue L = (l+n-1)//n R = (r+n-1)//n if L==R: for j in range(l,r): e[i].append(j) else: for j in range(l,n*L): e[i].append(j) e[j].append(i) for j in range(M+L,M+R-1): e[i].append(j) e[j].append(i) for j in range(n*(R-1),r): e[i].append(j) e[j].append(i) visited = [False]*(M+n) ans = [1]*(M+n) for i in range(N): if visited[i]: continue visited[i]=True v = deque() v.append(i) target = deque() target.append(i) cnt = 1 while v: x = v.popleft() for ix in e[x]: if visited[ix]: continue visited[ix] = True if ix<N: cnt += 1 target.append(ix) v.append(ix) while target: y = target.pop() ans[y] = cnt print(*ans[:N],sep='\n')