結果

問題 No.1508 Avoid being hit
ユーザー 👑 SPD_9X2SPD_9X2
提出日時 2021-05-14 23:35:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,509 bytes
コンパイル時間 143 ms
コンパイル使用メモリ 82,100 KB
実行使用メモリ 101,676 KB
最終ジャッジ日時 2024-04-10 04:12:41
合計ジャッジ時間 6,645 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
95,516 KB
testcase_01 AC 35 ms
53,832 KB
testcase_02 AC 35 ms
53,616 KB
testcase_03 AC 35 ms
53,356 KB
testcase_04 AC 37 ms
53,544 KB
testcase_05 AC 35 ms
52,956 KB
testcase_06 AC 35 ms
52,884 KB
testcase_07 AC 35 ms
52,196 KB
testcase_08 AC 36 ms
53,388 KB
testcase_09 AC 35 ms
52,888 KB
testcase_10 AC 34 ms
52,676 KB
testcase_11 AC 35 ms
52,600 KB
testcase_12 AC 34 ms
53,152 KB
testcase_13 AC 35 ms
53,620 KB
testcase_14 AC 34 ms
52,924 KB
testcase_15 AC 35 ms
52,936 KB
testcase_16 AC 81 ms
97,948 KB
testcase_17 AC 67 ms
89,144 KB
testcase_18 AC 60 ms
82,396 KB
testcase_19 AC 79 ms
98,560 KB
testcase_20 AC 89 ms
101,676 KB
testcase_21 AC 76 ms
92,372 KB
testcase_22 AC 83 ms
98,588 KB
testcase_23 AC 83 ms
98,272 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 AC 87 ms
92,916 KB
testcase_35 AC 53 ms
69,376 KB
testcase_36 AC 70 ms
87,056 KB
testcase_37 AC 56 ms
75,656 KB
testcase_38 AC 79 ms
94,384 KB
testcase_39 AC 71 ms
86,220 KB
testcase_40 AC 86 ms
95,064 KB
testcase_41 AC 77 ms
89,188 KB
testcase_42 AC 86 ms
95,336 KB
testcase_43 AC 94 ms
98,640 KB
testcase_44 AC 35 ms
52,676 KB
testcase_45 AC 33 ms
52,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

"""

言ってはいけないマス、は少ないはず
A,B が叩かれるとき、


"""

import sys
from sys import stdin
def able(i,x): #i回目の操作後にxにいて平気か?

    if A[i] == x or B[i] == x:
        return False
    if not llis[i+1] <= x <= rlis[i+1]:
        return False
    return True
    

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

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

llis = [1] #
rlis = [N] #i番目の操作前に、この範囲にいれば適切に動けば逃げられる範囲

for i in range(Q-1,-1,-1):

    a,b = min(A[i],B[i]),max(A[i],B[i])

    if a == llis[-1] and b == llis[-1] + 1:
        llis.append(llis[-1] + 1)
    elif a == llis[-1]:
        llis.append(llis[-1])
    else:
        llis.append(max(1,llis[-1] - 1))

    if b == rlis[-1] and a == rlis[-1] - 1:
        rlis.append(rlis[-1] - 1)
    elif b == rlis[-1]:
        rlis.append(rlis[-1])
    else:
        rlis.append(min(N,rlis[-1] + 1))

llis.reverse()
rlis.reverse()


for i in range(len(llis)):
    if llis[i] > rlis[i]:
        print ("NO")
        sys.exit()


#print (llis)
#print (rlis)

ans = []
ans.append(llis[0])

for i in range(Q):

    if able(i,max(1,ans[-1]-1)):
        ans.append(max(1,ans[-1]-1))

    elif able(i,ans[-1]):
        ans.append(ans[-1])

    elif able(i,min(N,ans[-1] + 1)):
        ans.append(min(N,ans[-1]+1))

    else:
        print ("NO")
        sys.exit()

print ("YES")
print ("\n".join(map(str,ans)))
0