結果
| 問題 |
No.2018 X-Y-X
|
| コンテスト | |
| ユーザー |
gew1fw
|
| 提出日時 | 2025-06-12 16:28:21 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 654 bytes |
| コンパイル時間 | 443 ms |
| コンパイル使用メモリ | 82,040 KB |
| 実行使用メモリ | 71,008 KB |
| 最終ジャッジ日時 | 2025-06-12 16:28:25 |
| 合計ジャッジ時間 | 3,475 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 23 |
ソースコード
n = int(input())
s = input().strip()
t = input().strip()
if s[0] != t[0] or s[-1] != t[-1]:
print(-1)
exit()
D = [0] * n
for i in range(n):
if s[i] != t[i]:
D[i] = 1
count = 0
possible = True
for j in range(1, n-1): # j is 0-based, from 1 to n-2 inclusive
if D[j] == 1:
if j == 1:
# Check if S[0] == S[2]
if s[0] != s[2]:
possible = False
break
else:
# Check if T[j-2] == original S[j]
if t[j-2] != s[j]:
possible = False
break
count += 1
if possible:
print(count)
else:
print(-1)
gew1fw