結果
| 問題 | No.2629 A replace B replace C | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2024-02-16 21:30:28 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 147 ms / 2,000 ms | 
| コード長 | 1,157 bytes | 
| コンパイル時間 | 356 ms | 
| コンパイル使用メモリ | 82,444 KB | 
| 実行使用メモリ | 90,020 KB | 
| 最終ジャッジ日時 | 2024-09-28 19:45:34 | 
| 合計ジャッジ時間 | 10,899 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 5 | 
| other | AC * 61 | 
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random
#sys.setrecursionlimit(10**9)
#sys.set_int_max_str_digits(0)
#input = sys.stdin.readline
n = int(input())
#alist = list(map(int,input().split()))
#alist = []
s = input()
#n,m = map(int,input().split())
#for i in range(n):
#    alist.append(list(map(int,input().split())))
t = input()
ss = []
tt = []
ab = 0
ac = 0
bc = 0
for i in range(n):
    if s[i] == 'A' and t[i] == 'A':
        continue
    if s[i] == 'A' and t[i] == 'B':
        ab += 1
    if s[i] == 'A' and t[i] == 'C':
        ac += 1
    if s[i] == 'B' and t[i] == 'A':
        print('No')
        exit()
    if s[i] == 'B' and t[i] == 'B':
        continue
    if s[i] == 'B' and t[i] == 'C':
        bc += 1
    if s[i] == 'C' and t[i] == 'A':
        print('No')
        exit()
    if s[i] == 'C' and t[i] == 'B':
        print('No')
        exit()
    if s[i] == 'C' and t[i] == 'C':
        continue
    
if bc == 0:
    if ac == ab == 0:
        print('Yes')
        exit()
    print('No')
    exit()
else:
    ac = 0
    if ab == bc:
        print('Yes')
    else:
        print('No')
    
            
            
            
        