結果
| 問題 |
No.2629 A replace B replace C
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-02-16 21:36:59 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 52 ms / 2,000 ms |
| コード長 | 716 bytes |
| コンパイル時間 | 214 ms |
| コンパイル使用メモリ | 82,644 KB |
| 実行使用メモリ | 66,940 KB |
| 最終ジャッジ日時 | 2024-09-28 19:51:23 |
| 合計ジャッジ時間 | 4,645 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 |
| other | AC * 61 |
ソースコード
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")