結果
問題 | No.2018 X-Y-X |
ユーザー | shotoyoo |
提出日時 | 2023-08-04 00:04:15 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 151 ms / 2,000 ms |
コード長 | 1,194 bytes |
コンパイル時間 | 206 ms |
コンパイル使用メモリ | 82,432 KB |
実行使用メモリ | 102,912 KB |
最終ジャッジ日時 | 2024-04-21 22:40:19 |
合計ジャッジ時間 | 5,784 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
54,400 KB |
testcase_01 | AC | 54 ms
54,272 KB |
testcase_02 | AC | 51 ms
54,400 KB |
testcase_03 | AC | 52 ms
54,272 KB |
testcase_04 | AC | 51 ms
54,400 KB |
testcase_05 | AC | 55 ms
54,272 KB |
testcase_06 | AC | 122 ms
83,584 KB |
testcase_07 | AC | 121 ms
84,608 KB |
testcase_08 | AC | 131 ms
95,360 KB |
testcase_09 | AC | 132 ms
95,360 KB |
testcase_10 | AC | 122 ms
93,824 KB |
testcase_11 | AC | 126 ms
95,360 KB |
testcase_12 | AC | 131 ms
95,488 KB |
testcase_13 | AC | 125 ms
84,096 KB |
testcase_14 | AC | 139 ms
86,784 KB |
testcase_15 | AC | 137 ms
88,832 KB |
testcase_16 | AC | 121 ms
82,048 KB |
testcase_17 | AC | 130 ms
86,400 KB |
testcase_18 | AC | 126 ms
84,224 KB |
testcase_19 | AC | 113 ms
83,200 KB |
testcase_20 | AC | 115 ms
83,456 KB |
testcase_21 | AC | 121 ms
82,432 KB |
testcase_22 | AC | 118 ms
82,560 KB |
testcase_23 | AC | 66 ms
65,408 KB |
testcase_24 | AC | 151 ms
101,120 KB |
testcase_25 | AC | 149 ms
93,440 KB |
testcase_26 | AC | 140 ms
102,912 KB |
testcase_27 | AC | 101 ms
80,128 KB |
testcase_28 | AC | 62 ms
62,720 KB |
testcase_29 | AC | 99 ms
79,616 KB |
testcase_30 | AC | 78 ms
71,040 KB |
testcase_31 | AC | 122 ms
87,040 KB |
testcase_32 | AC | 129 ms
86,528 KB |
ソースコード
import sys, random input = lambda : sys.stdin.readline().rstrip() write = lambda x: sys.stdout.write(x+"\n"); writef = lambda x: print("{:.12f}".format(x)) debug = lambda x: sys.stderr.write(x+"\n") YES="Yes"; NO="No"; pans = lambda v: print(YES if v else NO); INF=10**18 LI = lambda : list(map(int, input().split())); II=lambda : int(input()); SI=lambda : [ord(c)-ord("a") for c in input()] def debug(_l_): for s in _l_.split(): print(f"{s}={eval(s)}", end=" ") print() def dlist(*l, fill=0): if len(l)==1: return [fill]*l[0] ll = l[1:] return [dlist(*ll, fill=fill) for _ in range(l[0])] n = int(input()) s = [c=="B" for c in input()] t = [c=="B" for c in input()] if s[0]==t[0] and s[n-1]==t[n-1]: s = [s[i]^s[i+1] for i in range(n-1)] t = [t[i]^t[i+1] for i in range(n-1)] n -= 1 for i in range(1,n,2): s[i] ^= 1 t[i] ^= 1 if sum(s)!=sum(t): ans = -1 else: ans = 0 sind = [i for i in range(n) if s[i]] tind = [i for i in range(n) if t[i]] for i in range(len(sind)): ans += abs(sind[i]-tind[i]) else: ans = -1 if ans==-1: print(-1) else: print(ans)