結果

問題 No.1579 New Type of Nim
ユーザー c-yanc-yan
提出日時 2021-07-02 22:05:42
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 659 bytes
コンパイル時間 136 ms
コンパイル使用メモリ 10,844 KB
実行使用メモリ 8,000 KB
最終ジャッジ日時 2023-09-11 21:59:10
合計ジャッジ時間 1,945 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 15 ms
7,864 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 14 ms
7,848 KB
testcase_14 AC 15 ms
7,840 KB
testcase_15 WA -
testcase_16 AC 15 ms
7,840 KB
testcase_17 WA -
testcase_18 AC 15 ms
7,920 KB
testcase_19 WA -
testcase_20 AC 16 ms
7,840 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 15 ms
7,932 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 15 ms
7,860 KB
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 15 ms
7,896 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

A, B = map(int, input().split())

def f(a, b, turn):
    if a == 0 or b == 0:
        return turn
    if a >= 3:
        if f(2, b, turn ^ 1) == turn:
            return turn
    if a >= 2:
        if f(1, b, turn ^ 1) == turn:
            return turn
    if a >= 1:
        if f(0, b, turn ^ 1) == turn:
            return turn
    if b >= 3:
        if f(a, 2, turn ^ 1) == turn:
            return turn
    if b >= 2:
        if f(a, 1, turn ^ 1) == turn:
            return turn
    if b >= 1:
        if f(a, 0, turn ^ 1) == turn:
            return turn
    return turn ^ 1

turn = f(A, B, 0)
if turn == 0:
    print('P')
elif turn == 1:
    print('Q')
0