結果
| 問題 |
No.2018 X-Y-X
|
| コンテスト | |
| ユーザー |
siganai
|
| 提出日時 | 2022-07-22 23:00:03 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 869 bytes |
| コンパイル時間 | 172 ms |
| コンパイル使用メモリ | 82,312 KB |
| 実行使用メモリ | 94,708 KB |
| 最終ジャッジ日時 | 2024-07-04 07:35:45 |
| 合計ジャッジ時間 | 4,195 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 8 WA * 23 |
ソースコード
#!/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
fl = 0
j = 0
li = [0] * n
fll = [0] * n
for i in range(1,n-1):
if li[i]:
fl = 1 - fl
if (fl == 0 and s[i] != t[i]) or (fl == 1 and s[i] == t[i]):
j = max(j,i + 1)
while j < n and ((fll[j-2] == 0 and s[j-2] != s[j]) or (fll[j-2] == 1 and s[j-2] == s[j])):
j += 1
if j == n:
print(-1)
exit()
li[j] += 1
ans += j - i
j += 1
fl = 1 - fl
fll[i] = fl
print(ans)
siganai