結果

問題 No.1366 交換門松列・梅
ユーザー ThetaTheta
提出日時 2022-11-01 11:48:12
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 36 ms / 1,000 ms
コード長 798 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 10,976 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2023-09-23 05:43:12
合計ジャッジ時間 2,157 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 34 ms
9,796 KB
testcase_01 AC 34 ms
9,792 KB
testcase_02 AC 34 ms
9,736 KB
testcase_03 AC 33 ms
9,776 KB
testcase_04 AC 31 ms
9,792 KB
testcase_05 AC 33 ms
9,916 KB
testcase_06 AC 31 ms
9,684 KB
testcase_07 AC 33 ms
9,808 KB
testcase_08 AC 33 ms
9,800 KB
testcase_09 AC 34 ms
9,928 KB
testcase_10 AC 36 ms
9,772 KB
testcase_11 AC 32 ms
9,812 KB
testcase_12 AC 31 ms
9,880 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
from typing import Sequence


def is_kadomatsu(numbers: Sequence[int]) -> bool:
    assert len(numbers) == 3
    if numbers[0] == numbers[2]:
        return False

    if numbers[0] < numbers[1] and numbers[1] > numbers[2]:
        return True
    if numbers[0] > numbers[1] and numbers[1] < numbers[2]:
        return True

    return False


def main():
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    for idx1, idx2 in product(range(3), repeat=2):
        a_copy = a[:]
        b_copy = b[:]
        a_copy[idx1], b_copy[idx2] = b_copy[idx2], a_copy[idx1]
        if is_kadomatsu(a_copy) and is_kadomatsu(b_copy):
            print("Yes")
            return
    else:
        print("No")


if __name__ == "__main__":
    main()
0