結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
96,176 KB
testcase_01 AC 35 ms
53,624 KB
testcase_02 AC 35 ms
53,264 KB
testcase_03 AC 35 ms
52,540 KB
testcase_04 AC 36 ms
52,624 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 35 ms
52,892 KB
testcase_08 AC 34 ms
52,920 KB
testcase_09 AC 39 ms
52,408 KB
testcase_10 RE -
testcase_11 AC 36 ms
52,744 KB
testcase_12 AC 35 ms
53,972 KB
testcase_13 AC 34 ms
53,216 KB
testcase_14 AC 36 ms
54,116 KB
testcase_15 AC 36 ms
52,760 KB
testcase_16 AC 101 ms
98,576 KB
testcase_17 AC 75 ms
87,312 KB
testcase_18 AC 70 ms
83,336 KB
testcase_19 AC 92 ms
95,968 KB
testcase_20 AC 111 ms
101,732 KB
testcase_21 AC 89 ms
92,992 KB
testcase_22 AC 93 ms
98,708 KB
testcase_23 AC 99 ms
98,776 KB
testcase_24 AC 177 ms
101,928 KB
testcase_25 AC 154 ms
98,168 KB
testcase_26 AC 91 ms
77,052 KB
testcase_27 AC 123 ms
86,508 KB
testcase_28 AC 119 ms
87,036 KB
testcase_29 AC 171 ms
98,268 KB
testcase_30 AC 127 ms
88,400 KB
testcase_31 AC 153 ms
95,172 KB
testcase_32 AC 166 ms
98,252 KB
testcase_33 AC 106 ms
81,132 KB
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 AC 36 ms
52,860 KB
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 != b:
                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