結果
問題 | No.1170 Never Want to Walk |
ユーザー | Navier_Boltzmann |
提出日時 | 2022-10-05 03:57:44 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,948 bytes |
コンパイル時間 | 297 ms |
コンパイル使用メモリ | 82,736 KB |
実行使用メモリ | 848,864 KB |
最終ジャッジ日時 | 2024-06-09 21:14:58 |
合計ジャッジ時間 | 9,945 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 44 ms
57,440 KB |
testcase_01 | AC | 41 ms
56,780 KB |
testcase_02 | AC | 41 ms
56,468 KB |
testcase_03 | AC | 43 ms
57,844 KB |
testcase_04 | AC | 43 ms
57,476 KB |
testcase_05 | AC | 43 ms
56,604 KB |
testcase_06 | AC | 44 ms
56,256 KB |
testcase_07 | AC | 44 ms
57,912 KB |
testcase_08 | AC | 42 ms
57,036 KB |
testcase_09 | AC | 43 ms
57,172 KB |
testcase_10 | AC | 42 ms
57,588 KB |
testcase_11 | AC | 41 ms
58,184 KB |
testcase_12 | AC | 78 ms
76,884 KB |
testcase_13 | AC | 85 ms
77,412 KB |
testcase_14 | AC | 83 ms
77,116 KB |
testcase_15 | AC | 80 ms
77,352 KB |
testcase_16 | AC | 80 ms
77,028 KB |
testcase_17 | AC | 85 ms
76,980 KB |
testcase_18 | AC | 76 ms
77,384 KB |
testcase_19 | AC | 80 ms
77,072 KB |
testcase_20 | AC | 89 ms
77,064 KB |
testcase_21 | AC | 82 ms
77,020 KB |
testcase_22 | AC | 96 ms
77,940 KB |
testcase_23 | AC | 104 ms
77,756 KB |
testcase_24 | AC | 104 ms
77,688 KB |
testcase_25 | AC | 106 ms
77,772 KB |
testcase_26 | AC | 108 ms
77,616 KB |
testcase_27 | AC | 405 ms
135,436 KB |
testcase_28 | AC | 400 ms
135,940 KB |
testcase_29 | AC | 429 ms
131,396 KB |
testcase_30 | AC | 423 ms
135,904 KB |
testcase_31 | AC | 411 ms
133,476 KB |
testcase_32 | MLE | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
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<<60) 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')