結果

問題 No.1508 Avoid being hit
ユーザー vwxyzvwxyz
提出日時 2023-07-18 11:37:16
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,365 bytes
コンパイル時間 362 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 766,780 KB
最終ジャッジ日時 2023-10-18 14:42:26
合計ジャッジ時間 19,844 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 148 ms
88,808 KB
testcase_02 AC 147 ms
88,812 KB
testcase_03 AC 147 ms
88,804 KB
testcase_04 AC 147 ms
88,808 KB
testcase_05 AC 147 ms
88,808 KB
testcase_06 AC 147 ms
88,808 KB
testcase_07 AC 146 ms
88,808 KB
testcase_08 AC 147 ms
88,812 KB
testcase_09 AC 148 ms
88,808 KB
testcase_10 AC 147 ms
88,812 KB
testcase_11 AC 149 ms
88,804 KB
testcase_12 AC 150 ms
88,804 KB
testcase_13 AC 151 ms
88,804 KB
testcase_14 AC 151 ms
88,804 KB
testcase_15 AC 152 ms
88,808 KB
testcase_16 AC 2,006 ms
378,140 KB
testcase_17 AC 712 ms
176,528 KB
testcase_18 AC 1,027 ms
234,940 KB
testcase_19 AC 1,235 ms
258,024 KB
testcase_20 MLE -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import bisect
import copy
import decimal
import fractions
import heapq
import itertools
import math
import random
import sys
import time
from collections import Counter,deque,defaultdict
from functools import lru_cache,reduce
from heapq import heappush,heappop,heapify,heappushpop,_heappop_max,_heapify_max
def _heappush_max(heap,item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappushpop_max(heap, item):
    if heap and item < heap[0]:
        item, heap[0] = heap[0], item
        heapq._siftup_max(heap, 0)
    return item
from math import gcd as GCD
read=sys.stdin.read
readline=sys.stdin.readline
readlines=sys.stdin.readlines
write=sys.stdout.write

N,Q=map(int,readline().split())
A=list(map(int,readline().split()))
B=list(map(int,readline().split()))
for q in range(Q):
    A[q]-=1
    B[q]-=1
dp=[None]*(Q+1)
dp[0]=(1<<N)-1
for q in range(1,Q+1):
    dp[q]=dp[q-1]>>1|dp[q-1]|dp[q-1]<<1
    dp[q]&=~(1<<N)
    dp[q]&=~(1<<A[q-1])
    dp[q]&=~(1<<B[q-1])
if dp[Q]:
    print("YES")
    for x in range(N):
        if dp[Q]&1<<x:
            break
    ans_lst=[x]
    for q in range(Q-1,-1,-1):
        if 0<=x-1<N and dp[q]&1<<x-1:
            x-=1
        elif 0<=x+1<N and dp[q]&1<<x+1:
            x+=1
        ans_lst.append(x)
    ans_lst=ans_lst[::-1]
    print(*[x+1 for x in ans_lst],sep="\n")
else:
    print("NO")
0