結果

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

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n = int(input())
s = input().rstrip()
t = input().rstrip()

all = 0
ok = 1
cnt = 0
ab = 0
bc = 0
ac = 0
for i in range(n):
    if (ord(s[i])) > ord(t[i]):
        ok = 0
    if s[i] == "A" and t[i] == "C":
        ac += 1
    if s[i] == "B" and t[i] == "C":
        bc += 1
    if s[i] == "A" and t[i] == "B":
        ab += 1

if ok and ab == bc:
    if (ab == 0 and ac != 0):
        print('No')
    else:   
        print('Yes')
else:
    print('No')
0