結果
問題 | No.1170 Never Want to Walk |
ユーザー | Navier_Boltzmann |
提出日時 | 2022-10-05 04:01:58 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,834 bytes |
コンパイル時間 | 393 ms |
コンパイル使用メモリ | 87,232 KB |
実行使用メモリ | 849,488 KB |
最終ジャッジ日時 | 2023-08-29 21:54:12 |
合計ジャッジ時間 | 11,433 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 103 ms
72,872 KB |
testcase_01 | AC | 101 ms
72,688 KB |
testcase_02 | AC | 103 ms
72,716 KB |
testcase_03 | AC | 105 ms
72,704 KB |
testcase_04 | AC | 104 ms
72,624 KB |
testcase_05 | AC | 105 ms
72,792 KB |
testcase_06 | AC | 106 ms
72,668 KB |
testcase_07 | AC | 105 ms
72,856 KB |
testcase_08 | AC | 106 ms
72,576 KB |
testcase_09 | AC | 105 ms
72,620 KB |
testcase_10 | AC | 102 ms
72,840 KB |
testcase_11 | AC | 105 ms
72,664 KB |
testcase_12 | AC | 141 ms
78,556 KB |
testcase_13 | AC | 149 ms
79,728 KB |
testcase_14 | AC | 153 ms
80,036 KB |
testcase_15 | AC | 138 ms
78,060 KB |
testcase_16 | AC | 142 ms
80,044 KB |
testcase_17 | AC | 150 ms
80,072 KB |
testcase_18 | AC | 133 ms
77,980 KB |
testcase_19 | AC | 142 ms
79,732 KB |
testcase_20 | AC | 155 ms
80,272 KB |
testcase_21 | AC | 137 ms
78,500 KB |
testcase_22 | AC | 155 ms
79,960 KB |
testcase_23 | AC | 157 ms
80,060 KB |
testcase_24 | AC | 152 ms
80,320 KB |
testcase_25 | AC | 151 ms
80,288 KB |
testcase_26 | AC | 155 ms
80,232 KB |
testcase_27 | AC | 520 ms
137,224 KB |
testcase_28 | AC | 497 ms
137,684 KB |
testcase_29 | AC | 518 ms
133,424 KB |
testcase_30 | AC | 525 ms
138,668 KB |
testcase_31 | AC | 524 ms
135,824 KB |
testcase_32 | MLE | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
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) for j in range(M+L,M+R-1): e[i].append(j) for j in range(n*(R-1),r): e[i].append(j) 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) for j in range(M+L,M+R-1): e[i].append(j) for j in range(n*(R-1),r): e[i].append(j) 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')