結果

問題 No.2629 A replace B replace C
ユーザー flygonflygon
提出日時 2024-02-16 22:25:59
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 72 ms / 2,000 ms
コード長 676 bytes
コンパイル時間 578 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 72,896 KB
最終ジャッジ日時 2024-02-16 22:26:05
合計ジャッジ時間 5,912 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 52 ms
64,608 KB
testcase_01 AC 63 ms
70,252 KB
testcase_02 AC 65 ms
72,324 KB
testcase_03 AC 72 ms
72,896 KB
testcase_04 AC 70 ms
70,272 KB
testcase_05 AC 63 ms
70,252 KB
testcase_06 AC 58 ms
68,196 KB
testcase_07 AC 63 ms
70,264 KB
testcase_08 AC 56 ms
66,116 KB
testcase_09 AC 59 ms
68,180 KB
testcase_10 AC 69 ms
72,320 KB
testcase_11 AC 66 ms
72,320 KB
testcase_12 AC 70 ms
72,320 KB
testcase_13 AC 68 ms
72,324 KB
testcase_14 AC 60 ms
68,180 KB
testcase_15 AC 66 ms
70,252 KB
testcase_16 AC 68 ms
72,336 KB
testcase_17 AC 69 ms
72,320 KB
testcase_18 AC 66 ms
72,320 KB
testcase_19 AC 64 ms
70,268 KB
testcase_20 AC 65 ms
72,324 KB
testcase_21 AC 58 ms
66,116 KB
testcase_22 AC 56 ms
66,120 KB
testcase_23 AC 60 ms
68,184 KB
testcase_24 AC 58 ms
66,120 KB
testcase_25 AC 59 ms
66,116 KB
testcase_26 AC 58 ms
66,116 KB
testcase_27 AC 56 ms
66,124 KB
testcase_28 AC 57 ms
66,112 KB
testcase_29 AC 55 ms
66,120 KB
testcase_30 AC 56 ms
66,124 KB
testcase_31 AC 61 ms
68,188 KB
testcase_32 AC 59 ms
68,188 KB
testcase_33 AC 63 ms
68,812 KB
testcase_34 AC 62 ms
68,188 KB
testcase_35 AC 63 ms
68,184 KB
testcase_36 AC 60 ms
68,728 KB
testcase_37 AC 61 ms
68,180 KB
testcase_38 AC 61 ms
68,184 KB
testcase_39 AC 58 ms
68,180 KB
testcase_40 AC 62 ms
70,260 KB
testcase_41 AC 58 ms
66,120 KB
testcase_42 AC 57 ms
66,116 KB
testcase_43 AC 57 ms
66,116 KB
testcase_44 AC 55 ms
66,116 KB
testcase_45 AC 57 ms
68,192 KB
testcase_46 AC 60 ms
68,724 KB
testcase_47 AC 54 ms
66,116 KB
testcase_48 AC 55 ms
66,120 KB
testcase_49 AC 54 ms
66,116 KB
testcase_50 AC 58 ms
66,116 KB
testcase_51 AC 57 ms
66,116 KB
testcase_52 AC 54 ms
65,988 KB
testcase_53 AC 51 ms
63,928 KB
testcase_54 AC 51 ms
63,924 KB
testcase_55 AC 51 ms
66,124 KB
testcase_56 AC 51 ms
63,928 KB
testcase_57 AC 56 ms
66,116 KB
testcase_58 AC 53 ms
63,924 KB
testcase_59 AC 60 ms
68,180 KB
testcase_60 AC 56 ms
66,120 KB
testcase_61 AC 44 ms
55,720 KB
testcase_62 AC 44 ms
55,720 KB
testcase_63 AC 43 ms
55,720 KB
testcase_64 AC 44 ms
55,720 KB
testcase_65 AC 45 ms
55,720 KB
権限があれば一括ダウンロードができます

ソースコード

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