結果

問題 No.1508 Avoid being hit
ユーザー tpynerivertpyneriver
提出日時 2021-05-14 22:49:33
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,633 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 82,624 KB
実行使用メモリ 101,740 KB
最終ジャッジ日時 2024-04-10 01:57:03
合計ジャッジ時間 10,700 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
96,176 KB
testcase_01 AC 36 ms
53,288 KB
testcase_02 AC 38 ms
52,908 KB
testcase_03 AC 36 ms
52,132 KB
testcase_04 AC 35 ms
54,156 KB
testcase_05 WA -
testcase_06 RE -
testcase_07 AC 36 ms
52,648 KB
testcase_08 RE -
testcase_09 AC 36 ms
53,912 KB
testcase_10 RE -
testcase_11 AC 36 ms
52,960 KB
testcase_12 AC 35 ms
53,448 KB
testcase_13 AC 35 ms
53,260 KB
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 RE -
testcase_29 RE -
testcase_30 RE -
testcase_31 RE -
testcase_32 RE -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
readline = sys.stdin.readline

N, Q = map(int, readline().split())

ok = [None]*(Q+1)
ok[-1] = [(1, N+1)]

A = list(map(int, readline().split()))
B = list(map(int, readline().split()))


INF = 10**9+7
for i in range(Q):
    a, b = A[i], B[i]
    res = []
    for l, r in ok[i-1]:
        res.append((max(1, l-1), min(N+1, r+1)))
    
    st = -INF
    en = -INF
    
    res2 = []
    for l, r in res:
        if en < l:
            if st != en:
                res2.append((st, en))
            st = l
        en = r
    
    if st != en:
        res2.append((st, en))
    
    res3 = []
    for l, r in res2:
        if l <= a < r:
            if l != a:
                res3.append((l, a))
            if r-1 != a:
                res3.append((a+1, r))
        else:
            res3.append((l, r))
    
    res4 = []
    for l, r in res3:
        if l <= b < r:
            if l != b:
                res4.append((l, b))
            if r-1 != a:
                res4.append((b+1, r))
        else:
            res4.append((l, r))
    
    
    ok[i] = res4[:]


if not ok[N-1]:
    print("NO")
else:
    print("YES")
    ans = [ok[Q-1][0][0]]
    
    for i in range(Q-2, -1, -1):
        for l, r in ok[i]:
            if l <= ans[-1]-1 < r:
                ans.append(ans[-1]-1)
                break
            if l <= ans[-1] < r:
                ans.append(ans[-1])
                break
            if l <= ans[-1]+1 < r:
                ans.append(ans[-1]+1)
                break
        else:
            assert False
    
    ans.append(ans[-1])
    print('\n'.join(map(str, ans[::-1])))
    
    
    
    
0