結果

問題 No.1508 Avoid being hit
ユーザー vwxyzvwxyz
提出日時 2023-07-18 11:37:34
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
MLE  
実行時間 -
コード長 1,337 bytes
コンパイル時間 307 ms
コンパイル使用メモリ 11,916 KB
実行使用メモリ 815,848 KB
最終ジャッジ日時 2023-10-18 14:44:03
合計ジャッジ時間 13,783 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 MLE -
testcase_01 AC 39 ms
11,240 KB
testcase_02 AC 37 ms
11,240 KB
testcase_03 AC 37 ms
11,240 KB
testcase_04 AC 36 ms
11,240 KB
testcase_05 AC 37 ms
11,240 KB
testcase_06 AC 36 ms
11,240 KB
testcase_07 AC 37 ms
11,240 KB
testcase_08 AC 37 ms
11,240 KB
testcase_09 AC 36 ms
11,240 KB
testcase_10 AC 37 ms
11,240 KB
testcase_11 AC 36 ms
11,240 KB
testcase_12 AC 37 ms
11,240 KB
testcase_13 AC 37 ms
11,240 KB
testcase_14 AC 36 ms
11,240 KB
testcase_15 AC 38 ms
11,240 KB
testcase_16 AC 1,105 ms
321,680 KB
testcase_17 AC 410 ms
103,448 KB
testcase_18 AC 526 ms
166,136 KB
testcase_19 AC 721 ms
189,172 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