結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 144 ms
88,864 KB
testcase_02 AC 143 ms
88,864 KB
testcase_03 AC 141 ms
88,864 KB
testcase_04 AC 141 ms
88,868 KB
testcase_05 AC 144 ms
88,872 KB
testcase_06 AC 146 ms
88,864 KB
testcase_07 AC 143 ms
88,872 KB
testcase_08 AC 144 ms
88,868 KB
testcase_09 AC 143 ms
88,856 KB
testcase_10 AC 142 ms
88,860 KB
testcase_11 AC 146 ms
88,868 KB
testcase_12 AC 144 ms
88,864 KB
testcase_13 AC 142 ms
88,880 KB
testcase_14 AC 142 ms
88,872 KB
testcase_15 AC 146 ms
88,876 KB
testcase_16 AC 2,129 ms
378,328 KB
testcase_17 AC 752 ms
176,576 KB
testcase_18 AC 939 ms
234,976 KB
testcase_19 AC 1,346 ms
258,236 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|1<<A[q-1]|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