結果
問題 |
No.197 手品
|
ユーザー |
![]() |
提出日時 | 2016-07-19 14:55:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 30 ms / 1,000 ms |
コード長 | 974 bytes |
コンパイル時間 | 112 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-07-20 03:48:53 |
合計ジャッジ時間 | 2,440 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 43 |
ソースコード
# -*- coding: utf-8 -*- from collections import Counter s1 = input() N = int(input()) s2 = input() cs1 = Counter(s1) cs2 = Counter(s2) if cs1 != cs2: # カウンターが異なれば成功 print('SUCCESS') elif cs1['o'] * cs1['x'] == 0: # 以下はカウンターが等しいとき # すべて'o', すべて'x'ならすべてあり得るので失敗 print('FAILURE') else: # ('o', 'x') = (1, 2), (2, 1)のとき if N >= 2: print('FAILURE') elif N == 0: if s1 == s2: print('FAILURE') else: print('SUCCESS') else: # N == 1 # 少ない方の文字を取得 c = '' if cs1['o'] == 1: c = 'o' else: c = 'x' if s1.index(c) == s2.index(c) == 1: print('SUCCESS') elif s1.index(c) % 2 == 0 and abs(s1.index(c) - s2.index(c)) == 2: print('SUCCESS') else: print('FAILURE')