結果

問題 No.1508 Avoid being hit
ユーザー convexineqconvexineq
提出日時 2021-05-14 23:28:08
言語 PyPy3
(7.3.8)
結果
AC  
実行時間 267 ms / 3,000 ms
コード長 821 bytes
コンパイル時間 1,154 ms
使用メモリ 104,944 KB
最終ジャッジ日時 2022-11-26 01:02:42
合計ジャッジ時間 8,945 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
使用メモリ
testcase_00 AC 162 ms
100,696 KB
testcase_01 AC 64 ms
75,696 KB
testcase_02 AC 61 ms
75,600 KB
testcase_03 AC 61 ms
75,488 KB
testcase_04 AC 62 ms
75,752 KB
testcase_05 AC 64 ms
75,604 KB
testcase_06 AC 63 ms
75,748 KB
testcase_07 AC 62 ms
75,420 KB
testcase_08 AC 62 ms
75,692 KB
testcase_09 AC 61 ms
75,652 KB
testcase_10 AC 62 ms
75,700 KB
testcase_11 AC 64 ms
75,704 KB
testcase_12 AC 63 ms
75,764 KB
testcase_13 AC 63 ms
75,760 KB
testcase_14 AC 63 ms
75,768 KB
testcase_15 AC 62 ms
75,708 KB
testcase_16 AC 121 ms
102,568 KB
testcase_17 AC 107 ms
95,388 KB
testcase_18 AC 105 ms
90,344 KB
testcase_19 AC 121 ms
104,292 KB
testcase_20 AC 127 ms
102,744 KB
testcase_21 AC 113 ms
101,640 KB
testcase_22 AC 123 ms
102,708 KB
testcase_23 AC 126 ms
103,240 KB
testcase_24 AC 267 ms
104,944 KB
testcase_25 AC 244 ms
104,116 KB
testcase_26 AC 134 ms
82,544 KB
testcase_27 AC 206 ms
93,488 KB
testcase_28 AC 223 ms
93,324 KB
testcase_29 AC 240 ms
103,108 KB
testcase_30 AC 194 ms
94,776 KB
testcase_31 AC 246 ms
104,140 KB
testcase_32 AC 252 ms
104,768 KB
testcase_33 AC 176 ms
86,176 KB
testcase_34 AC 158 ms
100,556 KB
testcase_35 AC 105 ms
82,096 KB
testcase_36 AC 126 ms
92,556 KB
testcase_37 AC 119 ms
83,820 KB
testcase_38 AC 149 ms
96,856 KB
testcase_39 AC 139 ms
92,192 KB
testcase_40 AC 162 ms
100,684 KB
testcase_41 AC 130 ms
94,092 KB
testcase_42 AC 164 ms
100,256 KB
testcase_43 AC 155 ms
102,444 KB
testcase_44 AC 63 ms
75,740 KB
testcase_45 AC 64 ms
75,696 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