結果
| 問題 |
No.2018 X-Y-X
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 17:05:38 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 472 bytes |
| コンパイル時間 | 173 ms |
| コンパイル使用メモリ | 82,976 KB |
| 実行使用メモリ | 100,668 KB |
| 最終ジャッジ日時 | 2025-06-12 17:05:45 |
| 合計ジャッジ時間 | 3,281 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 23 |
ソースコード
n = int(input())
s = list(input())
t = list(input())
diff_positions = []
for i in range(n):
if s[i] != t[i]:
diff_positions.append(i)
count = 0
possible = True
for i in diff_positions:
if i < 1 or i >= n-1:
possible = False
break
if s[i-1] != s[i+1]:
possible = False
break
# Perform the operation
s[i] = 'B' if s[i] == 'A' else 'A'
count += 1
if possible and s == t:
print(count)
else:
print(-1)
gew1fw