結果

問題 No.2018 X-Y-X
ユーザー LyricalMaestroLyricalMaestro
提出日時 2024-05-08 03:05:00
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 533 bytes
コンパイル時間 230 ms
コンパイル使用メモリ 82,208 KB
実行使用メモリ 62,176 KB
最終ジャッジ日時 2024-12-14 03:01:29
合計ジャッジ時間 3,557 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 WA * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

## https://yukicoder.me/problems/no/2018


def main():
    N = int(input())
    S = input()
    T = input()

    if S[0] != T[0]:
        print(-1)
        return


    answer = 0
    for i in range(1, N - 1):
        if S[i] == T[i]:
            continue
        else:
            if T[i - 1] == S[i + 1]:
                answer += 1
            else:
                print(-1)
                return
    
    if S[-1] != T[-1]:
        print(-1)
        return
    print(answer)















if __name__ == "__main__":
    main()
0