結果

問題 No.1508 Avoid being hit
ユーザー convexineqconvexineq
提出日時 2021-05-14 23:28:08
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 226 ms / 3,000 ms
コード長 821 bytes
コンパイル時間 164 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 106,308 KB
最終ジャッジ日時 2024-04-10 05:34:47
合計ジャッジ時間 7,172 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 130 ms
100,304 KB
testcase_01 AC 38 ms
52,820 KB
testcase_02 AC 39 ms
53,264 KB
testcase_03 AC 37 ms
52,952 KB
testcase_04 AC 38 ms
52,820 KB
testcase_05 AC 37 ms
52,692 KB
testcase_06 AC 37 ms
52,668 KB
testcase_07 AC 37 ms
53,016 KB
testcase_08 AC 38 ms
52,996 KB
testcase_09 AC 38 ms
52,132 KB
testcase_10 AC 37 ms
53,092 KB
testcase_11 AC 38 ms
52,472 KB
testcase_12 AC 38 ms
52,536 KB
testcase_13 AC 38 ms
52,412 KB
testcase_14 AC 38 ms
52,720 KB
testcase_15 AC 37 ms
52,984 KB
testcase_16 AC 101 ms
102,856 KB
testcase_17 AC 83 ms
89,540 KB
testcase_18 AC 78 ms
84,416 KB
testcase_19 AC 97 ms
99,248 KB
testcase_20 AC 109 ms
102,136 KB
testcase_21 AC 93 ms
96,828 KB
testcase_22 AC 104 ms
103,156 KB
testcase_23 AC 105 ms
104,168 KB
testcase_24 AC 226 ms
106,308 KB
testcase_25 AC 206 ms
102,672 KB
testcase_26 AC 103 ms
77,196 KB
testcase_27 AC 180 ms
87,960 KB
testcase_28 AC 160 ms
87,956 KB
testcase_29 AC 200 ms
102,396 KB
testcase_30 AC 169 ms
89,780 KB
testcase_31 AC 179 ms
99,488 KB
testcase_32 AC 199 ms
102,572 KB
testcase_33 AC 133 ms
80,648 KB
testcase_34 AC 125 ms
97,620 KB
testcase_35 AC 65 ms
73,580 KB
testcase_36 AC 95 ms
86,644 KB
testcase_37 AC 86 ms
77,976 KB
testcase_38 AC 116 ms
92,464 KB
testcase_39 AC 108 ms
86,428 KB
testcase_40 AC 126 ms
100,208 KB
testcase_41 AC 96 ms
88,164 KB
testcase_42 AC 130 ms
99,908 KB
testcase_43 AC 125 ms
103,800 KB
testcase_44 AC 38 ms
54,556 KB
testcase_45 AC 38 ms
53,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n,Q = map(int,input().split())
*a, = map(int,input().split())
*b, = map(int,input().split())
L = [0]*Q
R = [0]*Q
l,r = 0,n-1

def check(v,lst,a,b):
    if v==a or v==b: return False
    return not(v-1 in lst and v in lst and v+1 in lst)

for i in range(Q)[::-1]:
    ai = a[i]-1
    bi = b[i]-1
    lst = [l-1,l-2,r+1,r+2]
    for ll in range(max(l-1,0),l+3):
        if check(ll,lst,ai,bi): break
    for rr in range(min(n-1,r+1),r-3,-1):
        if check(rr,lst,ai,bi): break
    L[i], R[i] = ll+1,rr+1
    l,r = ll,rr
    if ll > rr:
        print("NO")
        exit()

#print(L)
#print(R)
print("YES")
def ok(x,i):
    return x >= L[i] and x <= R[i] and x != a[i] and x != b[i]

v = L[0]
print(v)
for i in range(Q):
    for x in [v-1,v,v+1]:
        if ok(x,i): break
    else:
        assert 0
    v = x
    print(v)
0