結果

問題 No.2018 X-Y-X
ユーザー Kiri8128Kiri8128
提出日時 2022-05-04 00:31:26
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,040 bytes
コンパイル時間 286 ms
コンパイル使用メモリ 87,052 KB
実行使用メモリ 81,060 KB
最終ジャッジ日時 2023-09-16 19:58:44
合計ジャッジ時間 5,540 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,360 KB
testcase_01 AC 67 ms
71,380 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 69 ms
71,284 KB
testcase_05 AC 68 ms
71,252 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 118 ms
81,060 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 107 ms
77,840 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 103 ms
77,396 KB
testcase_29 AC 88 ms
76,928 KB
testcase_30 AC 110 ms
78,544 KB
testcase_31 WA -
testcase_32 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 雑提出(通らない)
N = int(input())
S = [ord(a) - 65 for a in input()]
T = [ord(a) - 65 for a in input()]
inf = 10 ** 9
null, m, lm, rm, lrm, mlrm, rmlrm, lmlrm,lrmlrm = 0, inf, inf, inf, inf, inf, inf, inf, inf
for i in range(1, N - 1):
    nnull, nm, nlm, nrm, nlrm, nmlrm, nrmlrm, nlmlrm, nlrmlrm = inf, inf, inf, inf, inf, inf, inf, inf, inf
    if S[i] == T[i]:
        nnull = min(null, m, lm)
        if S[i-1] == S[i+1]:
            nmlrm = min(rm, lrm, rmlrm, lrmlrm) + 2
            nlrmlrm = min(mlrm, lmlrm) + 2
        else:
            nrmlrm = min(rm, lrm, rmlrm, lrmlrm) + 2
            nlmlrm = min(mlrm, lmlrm) + 2
    else:
        if S[i-1] == S[i+1]:
            nm = min(null, rm, lrm) + 1
            nlrm = min(m, lm, mlrm, lmlrm) + 1
        else:
            nlm = min(m, lm, mlrm, lmlrm) + 1
            nrm = min(null, rm, lrm) + 1
    null, m, lm, rm, lrm, mlrm, rmlrm, lmlrm, lrmlrm = nnull, nm, nlm, nrm, nlrm, nmlrm, nrmlrm, nlmlrm, nlrmlrm
ans = min((null, m, lm))
print(ans if ans < inf else -1)
0