結果

問題 No.582 キャンディー・ボックス3
ユーザー yamasaKit_yamasaKit_
提出日時 2020-05-27 20:59:30
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 934 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-04-21 05:17:53
合計ジャッジ時間 1,384 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 27 ms
10,624 KB
testcase_01 WA -
testcase_02 AC 30 ms
10,752 KB
testcase_03 AC 27 ms
10,624 KB
testcase_04 AC 26 ms
10,624 KB
testcase_05 AC 26 ms
10,624 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 27 ms
10,496 KB
testcase_10 WA -
testcase_11 AC 26 ms
10,624 KB
testcase_12 AC 27 ms
10,624 KB
testcase_13 AC 26 ms
10,624 KB
testcase_14 WA -
testcase_15 AC 26 ms
10,496 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 26 ms
10,496 KB
testcase_19 AC 26 ms
10,624 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = sys.stdin.buffer.readline
N = int(input())
C = list(map(int, input().split()))

if sum(C) == 0:
    print('B')
    exit()

cnt_1 = 0
cnt_2 = 0
for c in C:
    if c == 1:
        cnt_1 += 1
        continue
    if c >= 2:
        cnt_2 += 1
    if cnt_2 >= 2:
        print('B')
        exit()
if cnt_2 == 1:
    if cnt_1 % 2 == 1:
        print('A')
        exit()
    else:
        print('B')
        exit()
if cnt_1 % 2 == 1:
    print('B')
    exit()
else:
    print('A')
    exit()

# 最後の1つまたは2つを取った人の勝ち
# 2以上はBが必ず勝てる,逆に言えばAが最後の1つを取れるようにすることもBはできる
# 値が2以上の箱が2つ以上あるときBは全てをコントロールすることができるのでBが必ず勝つ

# 1 2: A
# 1 1 2: B
# 1 1 1 2: A
# 1が奇数: Aの勝ち

# 1 1: B
# 1 1 1: A
# 1が奇数: Bの勝ち

# 全部0の場合: Bの勝ち
0