結果

問題 No.2402 Dirty Stairs and Shoes
ユーザー yassu0320yassu0320
提出日時 2023-08-05 02:12:54
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 2,221 bytes
コンパイル時間 174 ms
コンパイル使用メモリ 82,184 KB
実行使用メモリ 110,592 KB
最終ジャッジ日時 2024-05-10 07:23:58
合計ジャッジ時間 5,890 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
80,000 KB
testcase_01 AC 112 ms
79,872 KB
testcase_02 AC 99 ms
79,872 KB
testcase_03 AC 162 ms
100,736 KB
testcase_04 AC 115 ms
81,280 KB
testcase_05 AC 167 ms
110,592 KB
testcase_06 AC 117 ms
85,888 KB
testcase_07 AC 114 ms
81,344 KB
testcase_08 AC 123 ms
81,920 KB
testcase_09 AC 137 ms
92,800 KB
testcase_10 AC 149 ms
99,492 KB
testcase_11 AC 113 ms
86,492 KB
testcase_12 AC 112 ms
80,960 KB
testcase_13 AC 134 ms
93,824 KB
testcase_14 AC 157 ms
101,376 KB
testcase_15 AC 141 ms
93,052 KB
testcase_16 AC 110 ms
81,792 KB
testcase_17 AC 147 ms
96,332 KB
testcase_18 AC 137 ms
92,452 KB
testcase_19 AC 146 ms
99,320 KB
testcase_20 AC 150 ms
96,128 KB
testcase_21 AC 113 ms
80,880 KB
testcase_22 AC 109 ms
82,316 KB
testcase_23 AC 110 ms
82,008 KB
testcase_24 AC 110 ms
82,516 KB
testcase_25 AC 141 ms
98,620 KB
testcase_26 AC 119 ms
82,160 KB
testcase_27 AC 157 ms
99,468 KB
testcase_28 AC 144 ms
93,876 KB
testcase_29 AC 106 ms
82,232 KB
testcase_30 AC 110 ms
80,664 KB
testcase_31 AC 148 ms
99,764 KB
testcase_32 AC 108 ms
81,976 KB
testcase_33 AC 93 ms
79,844 KB
testcase_34 AC 113 ms
81,576 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env pypy3

import re
from collections import deque
from inspect import currentframe
from pprint import pprint
from string import ascii_lowercase as letter
from string import ascii_uppercase
from sys import setrecursionlimit, stderr, stdin
from time import sleep as _time_sleep
from typing import Dict, Generic, Iterable, Iterator, List, Optional, Set, Tuple, TypeVar, Union

try:
    import pypyjit
    pypyjit.set_param('max_unroll_recursion=-1')
except ModuleNotFoundError:
    ...

INF: int = (1 << 62) - 1
MOD1000000007 = 10**9 + 7
MOD998244353 = 998244353
setrecursionlimit(500_000)  # 5*10**5
readline = stdin.readline
input = lambda: stdin.readline().rstrip('\r\n')


def copy2d(a: list) -> list:
    return [[y for y in x] for x in a]


def copy3d(a: list) -> list:
    return [[[z for z in y] for y in x] for x in a]


def flattern2d(mat: list) -> list:
    return [x for a in mat for x in a]


IS_DEVELOPMENT = None


def debug(*a) -> None:
    global IS_DEVELOPMENT
    if IS_DEVELOPMENT is None:
        IS_DEVELOPMENT = __file__.endswith('/main.py')

    if not IS_DEVELOPMENT:
        return

    line_no = currentframe().f_back.f_lineno
    print(f"L{line_no}:", *a, file=stderr)


def inputs(type_=int, one_word=False) -> list:
    in_ = input()
    if one_word:
        ins = list(in_)
    else:
        ins = in_.split()

    if isinstance(type_, Iterable):
        return [t(x) for t, x in zip(type_, ins)]
    else:
        return list(map(type_, ins))


def inputi() -> int:
    return int(readline())


yn = ['no', 'yes']
Yn = ['No', 'Yes']
YN = ['NO', 'YES']

# start coding
n, k = inputs()

inputi()
tmp = inputs()
A = [0] * (n + 1)
for x in tmp:
    A[x] = 1

inputi()
tmp = inputs()
B = [0] * (n + 1)
for x in tmp:
    B[x] = 1

dp = [[False, False] for _ in range(n + 1)]
dp[0][1] = True
for i in range(1, n + 1):
    if A[i]:
        dp[i][0] = True
        dp[i][1] = False
        continue
    elif B[i]:
        dp[i][0] = False
        dp[i][1] = True
        continue

    for t in [1, k]:
        if not (0 <= i - t <= n):
            continue

        if A[i] == 0 and B[i] == 0:
            dp[i][0] |= dp[i - t][0]
            dp[i][1] |= dp[i - t][1]

print(Yn[dp[n][1]])
0