結果
| 問題 | No.2629 A replace B replace C |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-16 21:30:28 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
AC
|
| 実行時間 | 105 ms / 2,000 ms |
| コード長 | 1,157 bytes |
| 記録 | |
| コンパイル時間 | 359 ms |
| コンパイル使用メモリ | 85,056 KB |
| 実行使用メモリ | 86,980 KB |
| 最終ジャッジ日時 | 2026-04-15 08:32:17 |
| 合計ジャッジ時間 | 8,719 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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')