結果
問題 | No.2018 X-Y-X |
ユーザー |
![]() |
提出日時 | 2025-06-12 21:34:47 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 654 bytes |
コンパイル時間 | 274 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 70,272 KB |
最終ジャッジ日時 | 2025-06-12 21:36:47 |
合計ジャッジ時間 | 3,161 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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)