結果

問題 No.2209 Flip and Reverse
ユーザー ygd.ygd.
提出日時 2023-02-10 21:34:29
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 524 ms / 2,000 ms
コード長 1,130 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 10,816 KB
実行使用メモリ 34,352 KB
最終ジャッジ日時 2023-09-21 22:38:01
合計ジャッジ時間 12,861 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 19 ms
8,724 KB
testcase_01 AC 18 ms
8,716 KB
testcase_02 AC 18 ms
8,560 KB
testcase_03 AC 20 ms
8,704 KB
testcase_04 AC 20 ms
8,660 KB
testcase_05 AC 19 ms
8,704 KB
testcase_06 AC 20 ms
8,532 KB
testcase_07 AC 18 ms
8,520 KB
testcase_08 AC 506 ms
33,940 KB
testcase_09 AC 19 ms
8,720 KB
testcase_10 AC 19 ms
8,572 KB
testcase_11 AC 19 ms
8,704 KB
testcase_12 AC 19 ms
8,436 KB
testcase_13 AC 18 ms
8,544 KB
testcase_14 AC 518 ms
34,116 KB
testcase_15 AC 520 ms
33,084 KB
testcase_16 AC 519 ms
34,120 KB
testcase_17 AC 518 ms
32,892 KB
testcase_18 AC 519 ms
33,880 KB
testcase_19 AC 516 ms
33,660 KB
testcase_20 AC 519 ms
32,884 KB
testcase_21 AC 524 ms
33,148 KB
testcase_22 AC 520 ms
33,960 KB
testcase_23 AC 520 ms
34,352 KB
testcase_24 AC 511 ms
33,072 KB
testcase_25 AC 513 ms
33,652 KB
testcase_26 AC 511 ms
33,028 KB
testcase_27 AC 512 ms
34,108 KB
testcase_28 AC 498 ms
33,412 KB
testcase_29 AC 499 ms
33,668 KB
testcase_30 AC 502 ms
33,644 KB
testcase_31 AC 498 ms
33,624 KB
testcase_32 AC 498 ms
33,872 KB
testcase_33 AC 495 ms
34,300 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
#import math
import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
from collections import defaultdict
from collections import deque
#import copy #DeepCopy: hoge = [_[:] for _ in hogehoge]
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
MOD = 998244353
dx = [1,0,-1,0]
dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    N = int(input()); INF = 1 << 60
    S = list(str(input()))
    S = [int(a) for a in S]
    T = list(str(input()))
    T = [int(a) for a in T]
    ans = INF
    #偶数回で一致するときに必要な変更箇所
    en = 0
    for s,t in zip(S,T):
        if s != t:
            en += 1
    #奇数回で一致するときに必要な変更箇所
    on = 0
    for i in range(N):
        if S[i] != T[N-1-i]:
            on += 1
    if en%2 == 0:
        ans = min(ans,en)
    if on%2 == 1:
        ans = min(ans,on)
    print(ans)

if __name__ == '__main__':
    main()
0