結果
問題 | No.1170 Never Want to Walk |
ユーザー | Kiri8128 |
提出日時 | 2020-08-16 15:18:37 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 2,049 bytes |
コンパイル時間 | 803 ms |
コンパイル使用メモリ | 81,760 KB |
実行使用メモリ | 666,372 KB |
最終ジャッジ日時 | 2024-10-11 10:29:45 |
合計ジャッジ時間 | 8,223 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
59,648 KB |
testcase_01 | AC | 42 ms
54,528 KB |
testcase_02 | AC | 41 ms
54,144 KB |
testcase_03 | AC | 42 ms
54,400 KB |
testcase_04 | AC | 41 ms
54,400 KB |
testcase_05 | AC | 42 ms
54,272 KB |
testcase_06 | AC | 43 ms
54,272 KB |
testcase_07 | AC | 42 ms
53,888 KB |
testcase_08 | AC | 43 ms
54,272 KB |
testcase_09 | AC | 41 ms
54,400 KB |
testcase_10 | AC | 42 ms
54,016 KB |
testcase_11 | AC | 41 ms
54,144 KB |
testcase_12 | AC | 96 ms
78,196 KB |
testcase_13 | AC | 97 ms
77,704 KB |
testcase_14 | AC | 100 ms
77,440 KB |
testcase_15 | AC | 92 ms
77,376 KB |
testcase_16 | AC | 95 ms
77,568 KB |
testcase_17 | AC | 105 ms
77,844 KB |
testcase_18 | AC | 94 ms
77,436 KB |
testcase_19 | AC | 100 ms
77,832 KB |
testcase_20 | AC | 105 ms
77,912 KB |
testcase_21 | AC | 95 ms
77,696 KB |
testcase_22 | AC | 110 ms
77,952 KB |
testcase_23 | AC | 108 ms
77,568 KB |
testcase_24 | AC | 112 ms
77,952 KB |
testcase_25 | AC | 112 ms
77,768 KB |
testcase_26 | AC | 112 ms
77,924 KB |
testcase_27 | MLE | - |
testcase_28 | TLE | - |
testcase_29 | MLE | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
from bisect import bisect_right as br from collections import deque class range_edge: def __init__(self, n): self.k = (n-1).bit_length() self.K = 1 << self.k self.KK = self.K * 3 self.E = [[] for _ in range(self.KK)] for i in range(2, self.K * 2): self.E[i >> 1].append((i, 0)) for i in range(self.K, self.KK - 2): self.E[i].append((i + self.KK >> 1, 0)) self.c = self.KK # Number of Vertices def indices(self, l, r): l += self.K r += self.K while l < r: if l & 1: yield l l += 1 l >>= 1 if r & 1: r -= 1 yield r r >>= 1 def add_range_edge(self, a, b, c, d): # from [a, b) to [c, d) if a >= b or c >= d: return for i in self.indices(a - self.KK, b - self.KK): self.E[i + self.KK].append((self.c, 0)) self.c += 1 self.E.append([(self.c, 1)]) # cost = 1 self.E.append([]) for i in self.indices(c, d): self.E[self.c].append((i, 0)) self.c += 1 def BFS01(self, i0=0): i0 += self.K Q = deque([i0]) n = self.c D = [-1] * n D[i0] = 0 while Q: i = Q.popleft() for j, w in self.E[i]: if D[j] == -1: D[j] = D[i] + w if w: Q.append(j) else: Q.appendleft(j) return [i - self.K for i in range(self.K, self.K * 2) if D[i] >= 0] N, A, B = map(int, input().split()) re = range_edge(N) X = [int(a) for a in input().split()] for i in range(N): l = br(X, X[i] + A - 1) r = br(X, X[i] + B) re.add_range_edge(i, i + 1, l, r) re.add_range_edge(l, r, i, i + 1) ANS = [0] * N for i in range(N): if ANS[i]: continue bfs = re.BFS01(i) ans = len(bfs) for j in bfs: ANS[j] = ans print(*ANS, sep = "\n")