結果

問題 No.2629 A replace B replace C
ユーザー tassei903
提出日時 2024-02-11 16:25:18
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 50 ms / 2,000 ms
コード長 773 bytes
コンパイル時間 265 ms
コンパイル使用メモリ 82,584 KB
実行使用メモリ 71,696 KB
最終ジャッジ日時 2024-09-28 18:17:04
合計ジャッジ時間 4,737 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 5
other AC * 61
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input = lambda :sys.stdin.readline()[:-1]
ni = lambda :int(input())
na = lambda :list(map(int,input().split()))
yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES")
no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO")
######################################################################
n = int(input())
s = input()
t = input()

x1, x2, x3 = 0,0,0

for i in range(len(s)):
    if s[i] == t[i]:
        continue
    elif s[i] > t[i]:
        No()
        exit()
    elif s[i] == "A" and t[i] == "B":
        x1 += 1
    elif s[i] == "A" and t[i] == "C":
        x2 += 1
    elif s[i] == "B" and t[i] == "C":
        x3 += 1

if x1 == x2 == x3 == 0:
    Yes()
elif x1 == x3 and x1 > 0:
    Yes()
else:
    No()
0