結果

問題 No.1950 片道きゃっちぼーる
ユーザー ntudantuda
提出日時 2022-06-04 11:28:24
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 841 bytes
コンパイル時間 246 ms
コンパイル使用メモリ 81,884 KB
実行使用メモリ 274,904 KB
最終ジャッジ日時 2023-10-21 02:36:40
合計ジャッジ時間 7,051 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
55,632 KB
testcase_01 AC 45 ms
55,424 KB
testcase_02 AC 42 ms
55,424 KB
testcase_03 AC 329 ms
172,508 KB
testcase_04 TLE -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import deque

N = int(input())
X = list(map(int, input().split()))
A = list(map(int, input().split()))
S = set(X)
E = [[] for _ in range(N)]
T = [] # 落ちた場所と落とした人を記録
dic = dict(zip(X, range(N)))

for i, x in enumerate(X):
    a = A[i]
    if x + a in S:
        E[dic[x + a]].append(i)
    else:
        T.append((x + a, i))
    if x - a in S:
        E[dic[x - a]].append(i)
#print(E)
#print(T)

RP = [-1] * N  # 到達ポジション
for rpos, i in T:
    RP[i] = max(RP[i], rpos)
    visited = [0] * N
    q = deque()
    q.append(i)
    visited[i] = 1
    while len(q) > 0:
        u = q.pop()
        for v in E[u]:
            if visited[v] == 0:
                visited[v] = 1
                RP[v] = max(RP[v], rpos)
                q.append(v)

for i in range(N):
    print(RP[i] - X[i])
0