結果

問題 No.2018 X-Y-X
ユーザー とりゐとりゐ
提出日時 2022-08-08 15:52:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 87 ms / 2,000 ms
コード長 310 bytes
コンパイル時間 272 ms
コンパイル使用メモリ 81,748 KB
実行使用メモリ 89,696 KB
最終ジャッジ日時 2023-10-19 05:29:56
合計ジャッジ時間 4,665 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
53,364 KB
testcase_01 AC 39 ms
53,364 KB
testcase_02 AC 39 ms
53,364 KB
testcase_03 AC 39 ms
53,364 KB
testcase_04 AC 38 ms
53,364 KB
testcase_05 AC 39 ms
53,364 KB
testcase_06 AC 66 ms
76,056 KB
testcase_07 AC 71 ms
77,160 KB
testcase_08 AC 75 ms
83,548 KB
testcase_09 AC 75 ms
83,548 KB
testcase_10 AC 73 ms
86,196 KB
testcase_11 AC 79 ms
86,736 KB
testcase_12 AC 79 ms
87,016 KB
testcase_13 AC 72 ms
77,224 KB
testcase_14 AC 76 ms
78,892 KB
testcase_15 AC 77 ms
80,264 KB
testcase_16 AC 62 ms
74,292 KB
testcase_17 AC 75 ms
78,956 KB
testcase_18 AC 74 ms
77,716 KB
testcase_19 AC 53 ms
72,724 KB
testcase_20 AC 81 ms
85,016 KB
testcase_21 AC 68 ms
76,072 KB
testcase_22 AC 68 ms
76,020 KB
testcase_23 AC 40 ms
53,364 KB
testcase_24 AC 87 ms
88,184 KB
testcase_25 AC 83 ms
83,940 KB
testcase_26 AC 86 ms
89,696 KB
testcase_27 AC 48 ms
65,720 KB
testcase_28 AC 39 ms
53,364 KB
testcase_29 AC 57 ms
69,396 KB
testcase_30 AC 39 ms
53,364 KB
testcase_31 AC 76 ms
78,936 KB
testcase_32 AC 77 ms
79,412 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n=int(input())
s=input()
t=input()
if s[0]!=t[0] or s[-1]!=t[-1]:
  print(-1)
  exit()

a=[]
b=[]
for i in range(n-1):
  if (s[i]!=s[i+1])^(i%2):
    a.append(i)
  if (t[i]!=t[i+1])^(i%2):
    b.append(i)

if len(a)!=len(b):
  print(-1)
  exit()

ans=0
for i in range(len(a)):
  ans+=abs(a[i]-b[i])

print(ans)
0