結果

問題 No.3491 右結合的総乗
コンテスト
ユーザー kidodesu
提出日時 2026-04-03 21:51:15
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
AC  
実行時間 112 ms / 2,000 ms
コード長 373 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 232 ms
コンパイル使用メモリ 85,120 KB
実行使用メモリ 64,128 KB
最終ジャッジ日時 2026-04-03 21:51:28
合計ジャッジ時間 6,263 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 40
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

n, m = list(map(int, input().split()))
A = list(map(int, input().split()))
S = list(map(int, input().split()))
B = [0] * (n+1)
#C = [[0 for _ in range(n+1)] for _ in range(n+1)]
T = []
for s in S:
    B[s] = 1
    T.append(s)

while T:
    now = T.pop()
    for s in S:
        j = A[s + now]
        if not B[j]:
            B[j] = 1
            T.append(j)

print(sum(B))
0