結果

問題 No.3491 右結合的総乗
コンテスト
ユーザー kidodesu
提出日時 2026-04-03 21:44:44
言語 PyPy3
(7.3.17)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 543 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 221 ms
コンパイル使用メモリ 85,248 KB
実行使用メモリ 69,376 KB
最終ジャッジ日時 2026-04-03 21:45:22
合計ジャッジ時間 9,396 ms
ジャッジサーバーID
(参考情報)
judge5_1 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 25 WA * 15
権限があれば一括ダウンロードができます

ソースコード

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 i in range(n+1):
        if B[i]:
            j = A[i + now]
            if not B[j]:
                B[j] = 1
                T.append(j)

for i in range(n+1):
    if not B[i]: continue
    for j in range(n+1):
        if not B[j]: continue
        assert B[A[i+j]]

print(sum(B))
0