結果

問題 No.1170 Never Want to Walk
ユーザー Kiri8128Kiri8128
提出日時 2020-08-16 17:11:59
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,821 bytes
コンパイル時間 147 ms
コンパイル使用メモリ 82,356 KB
実行使用メモリ 378,812 KB
最終ジャッジ日時 2024-04-19 18:25:18
合計ジャッジ時間 18,093 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
        for i in range(self.K, self.KK - 2):
            self.E[i].append(i + self.KK >> 1)
        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)
        self.c += 1
        self.E.append([self.c]) # cost = 0
        self.E.append([])
        for i in self.indices(c, d):
            self.E[self.c].append(i)
        self.c += 1
    
    def BFS0(self, i0=0):
        K = self.K
        i0 += K
        Q = deque([i0])
        n = self.c
        done = {i0}
        while Q:
            i = Q.popleft()
            for j in self.E[i]:
                if j not in done:
                    done.add(j)
                    Q.append(j)
        return [a - K for a in done if K <= a < 2 * K]
    
    def debug(self):
        print("E =", self.E)

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)

print(*([1] * N), sep = "\n")
0