結果

問題 No.1579 New Type of Nim
ユーザー shotoyooshotoyoo
提出日時 2021-07-02 22:29:51
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 916 bytes
コンパイル時間 489 ms
コンパイル使用メモリ 87,240 KB
実行使用メモリ 76,600 KB
最終ジャッジ日時 2023-09-11 22:46:10
合計ジャッジ時間 4,711 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 85 ms
75,984 KB
testcase_03 AC 82 ms
76,296 KB
testcase_04 AC 82 ms
76,248 KB
testcase_05 AC 82 ms
76,444 KB
testcase_06 AC 79 ms
76,068 KB
testcase_07 AC 80 ms
76,108 KB
testcase_08 AC 79 ms
76,252 KB
testcase_09 AC 80 ms
76,288 KB
testcase_10 AC 81 ms
76,064 KB
testcase_11 AC 80 ms
76,448 KB
testcase_12 AC 80 ms
76,432 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 80 ms
76,320 KB
testcase_24 AC 80 ms
76,336 KB
testcase_25 AC 79 ms
76,440 KB
testcase_26 AC 79 ms
76,420 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 AC 80 ms
76,108 KB
testcase_30 WA -
testcase_31 AC 80 ms
76,380 KB
testcase_32 AC 80 ms
76,056 KB
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda : sys.stdin.readline().rstrip()

sys.setrecursionlimit(2*10**5+10)
write = lambda x: sys.stdout.write(x+"\n")
debug = lambda x: sys.stderr.write(x+"\n")
writef = lambda x: print("{:.12f}".format(x))


a,b = list(map(int, input().split()))
n = 20
dp = [[0]*n for _ in range(n)]
for i in range(n):
    for j in range(n):
        if i==j==0:
            continue
        ok = 0
        for k in range(1,i+1):
            if i-k==j:
                continue
            if dp[i-k][j]==0:
                ok = 1
#                 print(i,i-k,j)
        for k in range(1,j+1):
            if j-k==i:
                continue
            if dp[i][j-k]==0:
                ok = 1
        dp[i][j] = ok
if a==b:
    if a%2==0:
        ans = "Q"
    else:
        ans = "P"
elif abs(a-b)==1:
    v = min(a,b)
    if v%2==0:
        ans = "Q"
    else:
        ans = "P"
else:
    ans = "P"
print(ans)
0