結果

問題 No.197 手品
ユーザー maguroguma
提出日時 2017-09-16 01:52:07
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 30 ms / 1,000 ms
コード長 1,749 bytes
コンパイル時間 241 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-07-20 03:53:26
合計ジャッジ時間 2,525 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

# -*- coding: utf-8 -*-

S_before = input()
N = int(input())
S_after = input()

o_before = o_after = x_before = x_after = 0
for i in range(3):
    if S_before[i] == 'o':
        o_before += 1
    else:
        x_before += 1
    if S_after[i] == 'o':
        o_after += 1
    else:
        x_after += 1

if o_before != o_after:
    print('SUCCESS')
elif o_before == o_after and (o_before == 3 or o_before == 0):
    print('FAILURE')
else:
    # o_beforeとo_after,x_beforeとx_afterはそれぞれ等しく2以下
    if o_before < x_before:
        # コインが1つだけ入っている
        o_dist = abs(S_before.index('o') - S_after.index('o'))
        if o_dist == 0:
            if S_before.index('o') == 0 or S_before.index('o') == 2:
                print('FAILURE')
            elif N != 1:
                print('FAILURE')
            else:
                print('SUCCESS')
        elif o_dist == 1:
            if N >= 1:
                print('FAILURE')
            else:
                print('SUCCESS')
        else:
            if N >= 2:
                print('FAILURE')
            else:
                print('SUCCESS')
    else:
        # コインが2つはいっている
        x_dist = abs(S_before.index('x') - S_after.index('x'))
        if x_dist == 0:
            if S_before.index('x') == 0 or S_before.index('x') == 2:
                print('FAILURE')
            elif N != 1:
                print('FAILURE')
            else:
                print('SUCCESS')
        elif x_dist == 1:
            if N >= 1:
                print('FAILURE')
            else:
                print('SUCCESS')
        else:
            if N >= 2:
                print('FAILURE')
            else:
                print('SUCCESS')
0