結果

問題 No.2018 X-Y-X
ユーザー gew1fw
提出日時 2025-06-12 21:45:53
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 340 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 82,464 KB
実行使用メモリ 94,720 KB
最終ジャッジ日時 2025-06-12 21:49:55
合計ジャッジ時間 3,454 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = list(input().strip())
t = list(input().strip())

operations = 0

for i in range(n - 2):
    if s[i] != s[i + 2]:
        continue
    if s[i + 1] == t[i + 1]:
        continue
    # Perform the flip
    s[i + 1] = 'A' if s[i + 1] == 'B' else 'B'
    operations += 1

if s == t:
    print(operations)
else:
    print(-1)
0