結果

問題 No.1508 Avoid being hit
ユーザー convexineqconvexineq
提出日時 2021-05-14 23:26:43
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 822 bytes
コンパイル時間 161 ms
コンパイル使用メモリ 82,568 KB
実行使用メモリ 105,988 KB
最終ジャッジ日時 2024-04-10 03:54:05
合計ジャッジ時間 9,973 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 35 ms
52,956 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 36 ms
53,660 KB
testcase_06 AC 37 ms
52,636 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 37 ms
52,464 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 36 ms
52,620 KB
testcase_16 AC 102 ms
102,980 KB
testcase_17 AC 82 ms
89,456 KB
testcase_18 AC 76 ms
84,280 KB
testcase_19 AC 95 ms
99,280 KB
testcase_20 AC 107 ms
102,276 KB
testcase_21 AC 91 ms
96,368 KB
testcase_22 AC 99 ms
103,908 KB
testcase_23 AC 101 ms
103,584 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
testcase_41 WA -
testcase_42 WA -
testcase_43 WA -
testcase_44 WA -
testcase_45 AC 39 ms
53,344 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