結果
| 問題 | No.3774 Minimum Cost For Palindrome |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2026-10-23 21:30:37 |
| 言語 | PyPy3 (8.0.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 67 ms / 2,000 ms |
| + 234µs | |
| コード長 | 4,180 bytes |
| 記録 | |
| コンパイル時間 | 97 ms |
| コンパイル使用メモリ | 64,580 KB |
| 実行使用メモリ | 63,988 KB |
| 最終ジャッジ日時 | 2026-10-23 21:30:48 |
| 合計ジャッジ時間 | 3,816 ms |
|
ジャッジサーバーID (参考情報) |
judge1_0 / judge4_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 |
ソースコード
# AtCoder Competition Template v2.3.2 SHORT (PyPy 7.3.20 / Python 3.11)
# ↑ https://github.com/Rino-program/atcoder/blob/main/.template/main.py &template.py
# ALL: https://github.com/Rino-program/atcoder/blob/main/.template/template.py
import os, sys
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, accumulate, product, chain
#from sortedcontainers import SortedSet, SortedList, SortedDict
from bisect import bisect_left, bisect_right
from copy import deepcopy
import operator
import heapq
import math
import string
# ===== 設定・制限解除 =====
#sys.setrecursionlimit(2*10**6)
# ===== 入力ヘルパ =====
input = lambda: sys.stdin.readline().rstrip()
INT = lambda: int(input())
INT0 = lambda: int(input()) - 1
MAP = lambda: map(int, input().split())
MAP0 = lambda: (int(x) - 1 for x in input().split())
LIST = lambda: list(map(int, input().split()))
LIST0 = lambda: [int(x) - 1 for x in input().split()]
TUPLE = lambda: tuple(map(int, input().split()))
TUPLE0 = lambda: tuple(int(x) - 1 for x in input().split())
LISTS = lambda n: [list(map(int, input().split())) for _ in range(n)]
LISTS0 = lambda n: [[int(x) - 1 for x in input().split()] for _ in range(n)]
TUPLES = lambda n: [tuple(map(int, input().split())) for _ in range(n)]
TUPLES0 = lambda n: [tuple(int(x) - 1 for x in input().split()) for _ in range(n)]
LISTSI = lambda n: [int(input()) for _ in range(n)]
LISTSI0 = lambda n: [int(input()) - 1 for _ in range(n)]
STR = lambda: input()
STRS = lambda n: [input() for _ in range(n)]
CHARS = lambda: list(input())
CHARSL = lambda n: [list(input()) for _ in range(n)]
CHARSLI = lambda n: [list(map(int, input())) for _ in range(n)]
# ===== 高速 print =====
def print(*args, sep=' ', end='\n', file=None, flush=False):
file = file or sys.stdout
sep = ' ' if sep is None else sep
end = '\n' if end is None else end
file.write(sep.join(map(str, args)) + end)
flush and file.flush()
# ===== 定数 =====
INF = 10 ** 18
MOD = 998244353
# MOD = 10**9 + 7
# ===== 関数短縮 =====
pr = print
en = enumerate
hepu = heapq.heappush
hepo = heapq.heappop
bil = bisect_left
bir = bisect_right
dedict = defaultdict
# ===== 方向ベクトル(上(負)から時計回り) =====
DIR4 = ((-1, 0), (0, 1), (1, 0), (0, -1))
DIR8 = ((-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1))
DIR9 = DIR8 + ((0, 0),) # 中央は最後
# ===== 文字列のリスト =====
LOWER = list(string.ascii_lowercase) # 小文字 a-z の文字列リスト
UPPER = list(string.ascii_uppercase) # 大文字 A-Z の文字列リスト
DIGITS = list(string.digits) # 数字 0-9 の文字列リスト
# ===== よく使う出力関数 =====
Yes = lambda **kwargs: print("Yes", **kwargs)
No = lambda **kwargs: print("No", **kwargs)
yes = lambda **kwargs: print("yes", **kwargs)
no = lambda **kwargs: print("no", **kwargs)
YES = lambda **kwargs: print("YES", **kwargs)
NO = lambda **kwargs: print("NO", **kwargs)
def yn(cond: bool, yes: str = "Yes", no: str = "No", **kwargs) -> None:
"""条件に応じてYes/No出力"""
print(yes if cond else no, **kwargs)
def print_grid(grid: list[list], sep: str = '') -> None:
"""グリッド表示"""
print('\n'.join(sep.join(map(str, row)) for row in grid))
# ===== デバッグ =====
# AtCoder提出時は自動で無力化
if "ATCODER" not in os.environ and "ONLINE_JUDGE" not in os.environ:
def debug(*args, sep=' ', end='\n', flush=False) -> None:
"""デバッグ出力(標準エラー)"""
print("[DEBUG]", *args, sep=sep, end=end, file=sys.stderr, flush=flush)
else:
def debug(*args, **kwargs) -> None:
pass
# ===== template.py より引用コード =====
# ==============================================
# =================== main =====================
# ==============================================
def main() -> None:
# ここに解答を書く
S = STR()
if len(S) % 2 == 1:
S = S[:len(S)//2] + S[len(S)//2+1:]
ans = 0
for i in range(len(S)//2):
if S[i] != S[-i-1]:
ans += 1
print(ans)
if __name__ == "__main__":
main()