結果

問題 No.2629 A replace B replace C
ユーザー anonymouslyanonymously
提出日時 2024-02-16 23:05:01
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 71 ms / 2,000 ms
コード長 725 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-02-16 23:05:14
合計ジャッジ時間 7,364 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
10,880 KB
testcase_01 AC 44 ms
10,368 KB
testcase_02 AC 43 ms
10,368 KB
testcase_03 AC 48 ms
10,496 KB
testcase_04 AC 34 ms
10,240 KB
testcase_05 AC 36 ms
10,368 KB
testcase_06 AC 35 ms
10,368 KB
testcase_07 AC 51 ms
10,368 KB
testcase_08 AC 60 ms
10,368 KB
testcase_09 AC 69 ms
10,496 KB
testcase_10 AC 56 ms
10,496 KB
testcase_11 AC 68 ms
10,496 KB
testcase_12 AC 46 ms
10,624 KB
testcase_13 AC 44 ms
10,368 KB
testcase_14 AC 67 ms
10,496 KB
testcase_15 AC 55 ms
10,368 KB
testcase_16 AC 41 ms
10,368 KB
testcase_17 AC 40 ms
10,496 KB
testcase_18 AC 45 ms
10,496 KB
testcase_19 AC 36 ms
10,368 KB
testcase_20 AC 42 ms
10,368 KB
testcase_21 AC 65 ms
10,496 KB
testcase_22 AC 60 ms
10,368 KB
testcase_23 AC 64 ms
10,496 KB
testcase_24 AC 60 ms
10,496 KB
testcase_25 AC 60 ms
10,368 KB
testcase_26 AC 54 ms
10,368 KB
testcase_27 AC 54 ms
10,368 KB
testcase_28 AC 64 ms
10,496 KB
testcase_29 AC 51 ms
10,368 KB
testcase_30 AC 47 ms
10,240 KB
testcase_31 AC 31 ms
10,496 KB
testcase_32 AC 31 ms
10,624 KB
testcase_33 AC 30 ms
10,752 KB
testcase_34 AC 31 ms
10,368 KB
testcase_35 AC 30 ms
10,496 KB
testcase_36 AC 33 ms
10,624 KB
testcase_37 AC 31 ms
10,624 KB
testcase_38 AC 32 ms
10,496 KB
testcase_39 AC 33 ms
10,368 KB
testcase_40 AC 31 ms
10,624 KB
testcase_41 AC 54 ms
10,368 KB
testcase_42 AC 63 ms
10,496 KB
testcase_43 AC 60 ms
10,368 KB
testcase_44 AC 58 ms
10,368 KB
testcase_45 AC 70 ms
10,624 KB
testcase_46 AC 69 ms
10,624 KB
testcase_47 AC 58 ms
10,368 KB
testcase_48 AC 58 ms
10,368 KB
testcase_49 AC 49 ms
10,368 KB
testcase_50 AC 71 ms
10,496 KB
testcase_51 AC 60 ms
10,368 KB
testcase_52 AC 56 ms
10,368 KB
testcase_53 AC 40 ms
10,240 KB
testcase_54 AC 44 ms
10,240 KB
testcase_55 AC 44 ms
10,240 KB
testcase_56 AC 40 ms
10,240 KB
testcase_57 AC 64 ms
10,368 KB
testcase_58 AC 45 ms
10,240 KB
testcase_59 AC 65 ms
10,496 KB
testcase_60 AC 52 ms
10,368 KB
testcase_61 AC 31 ms
10,112 KB
testcase_62 AC 30 ms
10,112 KB
testcase_63 AC 31 ms
10,112 KB
testcase_64 AC 31 ms
10,112 KB
testcase_65 AC 32 ms
10,112 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def func(n,s,t):
    if s==t:
        return True
    a=b=c=0
    x=y=z=0
    for i in range(n):
        if s[i]>t[i]:
            return False
        elif s[i]<t[i]:
            if s[i]=='A':
                a+=1
            elif s[i]=='B':
                b+=1
            elif s[i]=='C':
                c+=1
            if t[i]=='A':
                x+=1
            elif t[i]=='B':
                y+=1
            elif t[i]=='C':
                z+=1
    if a<=x or b==0 or y==0 or b!=y or c>=z:
        return False
    p=b+2*c
    q=y+2*z
    if p>=q:
        return False
    elif (q-p)%2:
        return False
    return a-(q-p)//2==x and c+(q-p)//2==z

print("Yes" if func(int(input()),input(),input()) else "No")
0