結果

問題 No.2018 X-Y-X
ユーザー siganaisiganai
提出日時 2022-07-22 22:44:20
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 746 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 86,768 KB
実行使用メモリ 100,528 KB
最終ジャッジ日時 2023-09-17 11:16:40
合計ジャッジ時間 5,604 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 143 ms
83,028 KB
testcase_01 AC 147 ms
78,712 KB
testcase_02 AC 145 ms
78,692 KB
testcase_03 AC 144 ms
78,716 KB
testcase_04 AC 146 ms
78,664 KB
testcase_05 AC 146 ms
78,696 KB
testcase_06 AC 286 ms
99,432 KB
testcase_07 AC 295 ms
99,228 KB
testcase_08 TLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
from heapq import *
import functools
mod=998244353

import sys
input=sys.stdin.readline

n = int(input())
s = list(input().rstrip())
t = list(input().rstrip())
if s[0] != t[0] or s[-1] != t[-1]:
    print(-1)
    exit()
ans = 0
for i in range(1,n):
    if s[i] != t[i]:
        j = i + 1
        while j < n and s[j-2] != s[j]:
            j += 1
        if j == n:
            print(-1)
            exit()
        for k in range(j-1,i-1,-1):
            if s[k] == 'A':
                s[k] = 'B'
            else:
                s[k] = 'A'
            ans += 1
print(ans)
0