結果

問題 No.2018 X-Y-X
ユーザー gew1fw
提出日時 2025-06-12 17:08:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 340 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 82,500 KB
実行使用メモリ 95,296 KB
最終ジャッジ日時 2025-06-12 17:08:31
合計ジャッジ時間 3,479 ms
ジャッジサーバーID
(参考情報)
judge4 / 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