提出 #51329053


ソースコード 拡げる

from collections import defaultdict, deque
import bisect
import math
from heapq import *
import itertools
import sys
sys.setrecursionlimit(10**8)

N, H, W = map(int,input().split())
tiles = [list(map(int, input().split())) for _ in range(N)]

def dfs(i, H, W):
    # print(f'dfs({i}, {H}, {W})')
    res = False
    if H == 0 or W == 0:
        return True
    if i == N:
        return False
    # 順向きに置く
    if tiles[i][0] <= H and tiles[i][1] <= W:
        res = dfs(i+1, H-tiles[i][0], tiles[i][1]) and dfs(i+1, H, W-tiles[i][1])
        if res:
            return res
    # 倒して置く
    if tiles[i][1] <= H and tiles[i][0] <= W:
        res = dfs(i+1, H-tiles[i][1], tiles[i][0]) and dfs(i+1, H, W-tiles[i][0])
        if res:
            return res
    # 置かない
    res = dfs(i+1, H, W)
    return res


res = dfs(0, H, W)
if res:
    print('Yes')
else:
    print('No')

提出情報

提出日時
問題 D - Tiling
ユーザ flourpoke
言語 Python (PyPy 3.10-v7.3.12)
得点 0
コード長 900 Byte
結果 WA
実行時間 82 ms
メモリ 81084 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 0 / 450
結果
AC × 4
AC × 70
WA × 12
セット名 テストケース
Sample example_00.txt, example_01.txt, example_02.txt, example_03.txt
All example_00.txt, example_01.txt, example_02.txt, example_03.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, hand_06.txt, hand_07.txt, hand_08.txt, hand_09.txt, hand_10.txt, hand_11.txt, hand_12.txt, hand_13.txt, hand_14.txt, hand_15.txt, hand_16.txt, hand_17.txt, hand_18.txt, hand_19.txt, hand_20.txt, hand_21.txt, hand_22.txt, hand_23.txt, hand_24.txt, hand_25.txt, hand_26.txt, hand_27.txt, hand_28.txt, hand_29.txt, hand_30.txt, hand_31.txt, hand_32.txt, hand_33.txt, hand_34.txt, hand_35.txt, random2_00.txt, random2_01.txt, random2_02.txt, random2_03.txt, random2_04.txt, random2_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, random_25.txt, random_26.txt, random_27.txt, random_28.txt, random_29.txt, random_30.txt, random_31.txt, random_32.txt, random_33.txt, random_34.txt, random_35.txt
ケース名 結果 実行時間 メモリ
example_00.txt AC 79 ms 76924 KiB
example_01.txt AC 73 ms 76832 KiB
example_02.txt AC 73 ms 76836 KiB
example_03.txt AC 76 ms 77048 KiB
hand_00.txt WA 75 ms 76856 KiB
hand_01.txt AC 74 ms 76828 KiB
hand_02.txt AC 78 ms 76996 KiB
hand_03.txt AC 81 ms 76840 KiB
hand_04.txt AC 72 ms 76708 KiB
hand_05.txt AC 79 ms 80616 KiB
hand_06.txt AC 74 ms 77044 KiB
hand_07.txt AC 73 ms 77000 KiB
hand_08.txt WA 77 ms 76836 KiB
hand_09.txt AC 76 ms 76856 KiB
hand_10.txt AC 75 ms 76856 KiB
hand_11.txt AC 77 ms 76952 KiB
hand_12.txt AC 77 ms 77000 KiB
hand_13.txt AC 78 ms 76792 KiB
hand_14.txt AC 78 ms 77012 KiB
hand_15.txt AC 77 ms 76788 KiB
hand_16.txt AC 76 ms 76968 KiB
hand_17.txt AC 74 ms 76840 KiB
hand_18.txt AC 75 ms 77000 KiB
hand_19.txt AC 76 ms 76824 KiB
hand_20.txt AC 76 ms 76832 KiB
hand_21.txt AC 80 ms 76988 KiB
hand_22.txt AC 76 ms 76964 KiB
hand_23.txt AC 74 ms 76952 KiB
hand_24.txt AC 77 ms 76836 KiB
hand_25.txt AC 76 ms 77032 KiB
hand_26.txt AC 82 ms 81084 KiB
hand_27.txt AC 75 ms 76868 KiB
hand_28.txt AC 77 ms 80916 KiB
hand_29.txt AC 74 ms 77020 KiB
hand_30.txt AC 78 ms 77052 KiB
hand_31.txt AC 77 ms 76780 KiB
hand_32.txt AC 80 ms 77160 KiB
hand_33.txt AC 74 ms 76776 KiB
hand_34.txt AC 73 ms 76920 KiB
hand_35.txt WA 75 ms 76824 KiB
random2_00.txt AC 74 ms 76972 KiB
random2_01.txt AC 75 ms 76708 KiB
random2_02.txt AC 75 ms 76852 KiB
random2_03.txt AC 74 ms 76768 KiB
random2_04.txt AC 76 ms 76980 KiB
random2_05.txt AC 76 ms 76684 KiB
random_00.txt AC 74 ms 76824 KiB
random_01.txt WA 77 ms 76832 KiB
random_02.txt AC 78 ms 76924 KiB
random_03.txt AC 76 ms 76828 KiB
random_04.txt AC 76 ms 76988 KiB
random_05.txt AC 76 ms 76812 KiB
random_06.txt AC 77 ms 77036 KiB
random_07.txt WA 76 ms 77028 KiB
random_08.txt AC 75 ms 77036 KiB
random_09.txt AC 75 ms 77040 KiB
random_10.txt AC 75 ms 76764 KiB
random_11.txt AC 74 ms 77048 KiB
random_12.txt AC 74 ms 77004 KiB
random_13.txt AC 76 ms 76736 KiB
random_14.txt AC 78 ms 76732 KiB
random_15.txt AC 75 ms 76784 KiB
random_16.txt AC 75 ms 77056 KiB
random_17.txt AC 79 ms 76860 KiB
random_18.txt AC 79 ms 76920 KiB
random_19.txt AC 77 ms 77200 KiB
random_20.txt AC 79 ms 77040 KiB
random_21.txt WA 76 ms 76972 KiB
random_22.txt AC 79 ms 76856 KiB
random_23.txt AC 75 ms 76780 KiB
random_24.txt WA 75 ms 76928 KiB
random_25.txt AC 75 ms 76920 KiB
random_26.txt AC 74 ms 76844 KiB
random_27.txt WA 77 ms 76728 KiB
random_28.txt AC 76 ms 77156 KiB
random_29.txt AC 73 ms 76676 KiB
random_30.txt WA 75 ms 76920 KiB
random_31.txt AC 74 ms 77108 KiB
random_32.txt AC 73 ms 76992 KiB
random_33.txt WA 75 ms 76712 KiB
random_34.txt WA 79 ms 76744 KiB
random_35.txt WA 73 ms 76928 KiB