結果

問題 No.197 手品
ユーザー sue_charo
提出日時 2017-04-17 18:21:36
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 70 ms / 1,000 ms
コード長 1,718 bytes
コンパイル時間 572 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 66,304 KB
最終ジャッジ日時 2024-07-20 03:52:05
合計ジャッジ時間 4,480 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます

ソースコード

diff #

# coding: utf-8
import array, bisect, collections, heapq, itertools, math, random, re, string, sys, time
sys.setrecursionlimit(10 ** 7)
INF = 10 ** 20
MOD = 10 ** 9 + 7
 
 
def II(): return int(input())
def ILI(): return list(map(int, input().split()))
def IAI(LINE): return [ILI() for __ in range(LINE)]
def IDI(): return {key: value for key, value in ILI()}
 
 
def solve(S_bef, N, S_aft):
    bef_list = list(S_bef)
    aft_list = list(S_aft)
    bef_count = 0
    aft_count = 0
    for bef, aft in zip(bef_list, aft_list):
        if bef == "o":
            bef_count += 1
        if aft == "o":
            aft_count += 1
    
    if bef_count != aft_count:
        return "SUCCESS"
    else:
        if N == 0:
            if S_bef == S_aft:
                return "FAILURE"
            else:
                return "SUCCESS"
        elif N == 1:
            if bef_count == 1:
                if S_bef == "oxx" and S_aft == "xxo":
                    return "SUCCESS"
                elif S_bef == "xox" and S_aft == "xox":
                    return "SUCCESS"
                elif S_bef == "xxo" and S_aft == "oxx":
                    return "SUCCESS"
                
            elif bef_count == 2:
                if S_bef == "xoo" and S_aft == "oox":
                    return "SUCCESS"
                elif S_bef == "oxo" and S_aft == "oxo":
                    return "SUCCESS"
                elif S_bef == "oox" and S_aft == "xoo":
                    return "SUCCESS"
        
        else:
            return "FAILURE"
            
    return "FAILURE"

 
def main():
    S_bef = input()
    N = II()
    S_aft = input()
    print(solve(S_bef, N, S_aft))
 
 
if __name__ == "__main__":
    main()
0