結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 47 ms
60,344 KB
testcase_01 AC 51 ms
63,904 KB
testcase_02 AC 51 ms
63,912 KB
testcase_03 AC 53 ms
64,488 KB
testcase_04 AC 51 ms
63,912 KB
testcase_05 AC 49 ms
63,912 KB
testcase_06 AC 42 ms
59,572 KB
testcase_07 AC 50 ms
63,912 KB
testcase_08 AC 56 ms
65,984 KB
testcase_09 AC 57 ms
65,980 KB
testcase_10 AC 51 ms
63,904 KB
testcase_11 AC 55 ms
63,908 KB
testcase_12 AC 50 ms
63,904 KB
testcase_13 AC 53 ms
63,904 KB
testcase_14 AC 55 ms
65,980 KB
testcase_15 AC 52 ms
63,908 KB
testcase_16 AC 50 ms
63,908 KB
testcase_17 AC 50 ms
63,904 KB
testcase_18 AC 50 ms
63,904 KB
testcase_19 AC 48 ms
63,912 KB
testcase_20 AC 50 ms
63,904 KB
testcase_21 AC 54 ms
65,980 KB
testcase_22 AC 53 ms
63,912 KB
testcase_23 AC 56 ms
65,976 KB
testcase_24 AC 55 ms
65,980 KB
testcase_25 AC 54 ms
65,992 KB
testcase_26 AC 53 ms
65,988 KB
testcase_27 AC 56 ms
65,992 KB
testcase_28 AC 56 ms
65,980 KB
testcase_29 AC 54 ms
65,988 KB
testcase_30 AC 52 ms
63,912 KB
testcase_31 AC 38 ms
53,460 KB
testcase_32 AC 38 ms
53,460 KB
testcase_33 AC 38 ms
54,100 KB
testcase_34 AC 38 ms
53,460 KB
testcase_35 AC 38 ms
53,460 KB
testcase_36 AC 39 ms
53,972 KB
testcase_37 AC 38 ms
53,460 KB
testcase_38 AC 39 ms
53,460 KB
testcase_39 AC 39 ms
53,460 KB
testcase_40 AC 39 ms
53,460 KB
testcase_41 AC 55 ms
65,988 KB
testcase_42 AC 56 ms
65,988 KB
testcase_43 AC 57 ms
65,976 KB
testcase_44 AC 56 ms
65,976 KB
testcase_45 AC 59 ms
65,980 KB
testcase_46 AC 59 ms
66,524 KB
testcase_47 AC 56 ms
65,984 KB
testcase_48 AC 55 ms
65,992 KB
testcase_49 AC 54 ms
63,908 KB
testcase_50 AC 57 ms
65,984 KB
testcase_51 AC 56 ms
65,984 KB
testcase_52 AC 51 ms
63,908 KB
testcase_53 AC 49 ms
61,848 KB
testcase_54 AC 48 ms
61,716 KB
testcase_55 AC 50 ms
61,712 KB
testcase_56 AC 48 ms
61,716 KB
testcase_57 AC 58 ms
65,984 KB
testcase_58 AC 49 ms
61,832 KB
testcase_59 AC 58 ms
65,976 KB
testcase_60 AC 51 ms
63,912 KB
testcase_61 AC 37 ms
53,460 KB
testcase_62 AC 37 ms
53,460 KB
testcase_63 AC 37 ms
53,460 KB
testcase_64 AC 37 ms
53,460 KB
testcase_65 AC 38 ms
53,460 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#sys.setrecursionlimit((1<<19)-1)
#import pypyjit
#pypyjit.set_param('max_unroll_recursion=-1')
input=sys.stdin.buffer.readline

N=int(input())
S=input().decode().rstrip("\n")
T=input().decode().rstrip("\n")
two=0
a=0
b=0
for i in range(N):
    if S[i]=="C" and T[i]!="C":
        print("No")
        exit()
    if S[i]=="B" and T[i]=="A":
        print("No")
        exit()
    if S[i]=="A" and T[i]=="B":
        a+=1
    if S[i]=="A" and T[i]=="C":
        two+=1
    if S[i]=="B" and T[i]=="C":
        b+=1
while two+a+b>0:
    if b==0:
        print("No")
        exit()
    if two!=0:
        two-=1
    elif a!=0:
        a-=1
        b-=1
    else:
        print("No")
        exit()
print("Yes")
0