Submission #15263014
Source Code Expand
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.buffer.readline
INF = 10 ** 9 + 1 # sys.maxsize # float("inf")
MOD = 10 ** 9 + 7
def debug(*x):
print(*x, file=sys.stderr)
def solve(S):
ret = 0
N = len(S)
if N == 1:
return 0
xs = [S[i] != S[-1-i] for i in range(N // 2)]
sums = sum(xs)
for x in xs:
if x:
if sums == 1:
ret += 24 * 2
else:
ret += 25 * 2
else:
ret += 25 * 2
if N & 1:
if sums != 0:
ret += 25
return ret
def main():
# parse input
S = input().strip().decode('ascii')
print(solve(S))
# tests
T2 = """
ARC
"""
TEST_T2 = """
>>> as_input(T2)
>>> main()
73
"""
T3 = """
NOLEMONNOMELON
"""
TEST_T3 = """
>>> as_input(T3)
>>> main()
350
"""
T4 = """
ABA
"""
TEST_T4 = """
>>> as_input(T4)
>>> main()
50
"""
T5 = """
AA
"""
TEST_T5 = """
>>> as_input(T5)
>>> main()
50
"""
T6 = """
AB
"""
TEST_T6 = """
>>> as_input(T6)
>>> main()
48
"""
def _test():
import doctest
doctest.testmod()
g = globals()
for k in sorted(g):
if k.startswith("TEST_"):
doctest.run_docstring_examples(g[k], g)
def as_input(s):
"use in test, use given string as input file"
import io
global read, input
f = io.StringIO(s.strip())
def input():
return bytes(f.readline(), "ascii")
def read():
return bytes(f.read(), "ascii")
input = sys.stdin.buffer.readline
read = sys.stdin.buffer.read
if sys.argv[-1] == "-t":
print("testing")
_test()
sys.exit()
main()
Submission Info
| Submission Time | |
|---|---|
| Task | B - こだわりの名前 |
| User | nishiohirokazu |
| Language | PyPy3 (7.3.0) |
| Score | 100 |
| Code Size | 1753 Byte |
| Status | AC |
| Exec Time | 81 ms |
| Memory | 84592 KiB |
Judge Result
| Set Name | All | ||
|---|---|---|---|
| Score / Max Score | 100 / 100 | ||
| Status |
|
| Set Name | Test Cases |
|---|---|
| All | hand_1.txt, hand_2.txt, hand_3.txt, hand_4.txt, hand_5.txt, hand_6.txt, palindrome_1.txt, palindrome_12345.txt, palindrome_2.txt, palindrome_299998.txt, palindrome_299999.txt, palindrome_3.txt, palindrome_300000.txt, palindrome_4.txt, palindrome_5.txt, palindrome_6789.txt, palindrome_67890.txt, palindrome_mod_1.txt, palindrome_mod_1000.txt, palindrome_mod_10000.txt, palindrome_mod_100001.txt, palindrome_mod_2.txt, palindrome_mod_200000.txt, palindrome_mod_299999.txt, palindrome_mod_3.txt, palindrome_mod_300000.txt, palindrome_mod_4.txt, palindrome_mod_5.txt, palindrome_mod_50001.txt, random_1.txt, random_10.txt, random_100001.txt, random_101.txt, random_3000.txt, random_300000.txt, random_50001.txt, sample_1.txt, sample_2.txt, sample_3.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| hand_1.txt | AC | 81 ms | 81996 KiB |
| hand_2.txt | AC | 76 ms | 84056 KiB |
| hand_3.txt | AC | 74 ms | 84332 KiB |
| hand_4.txt | AC | 75 ms | 84592 KiB |
| hand_5.txt | AC | 75 ms | 84412 KiB |
| hand_6.txt | AC | 74 ms | 84244 KiB |
| palindrome_1.txt | AC | 53 ms | 62072 KiB |
| palindrome_12345.txt | AC | 55 ms | 65320 KiB |
| palindrome_2.txt | AC | 52 ms | 62152 KiB |
| palindrome_299998.txt | AC | 69 ms | 81844 KiB |
| palindrome_299999.txt | AC | 71 ms | 81476 KiB |
| palindrome_3.txt | AC | 52 ms | 62044 KiB |
| palindrome_300000.txt | AC | 67 ms | 82012 KiB |
| palindrome_4.txt | AC | 52 ms | 62160 KiB |
| palindrome_5.txt | AC | 51 ms | 62204 KiB |
| palindrome_6789.txt | AC | 55 ms | 65096 KiB |
| palindrome_67890.txt | AC | 58 ms | 68444 KiB |
| palindrome_mod_1.txt | AC | 51 ms | 62072 KiB |
| palindrome_mod_1000.txt | AC | 53 ms | 62224 KiB |
| palindrome_mod_10000.txt | AC | 55 ms | 65020 KiB |
| palindrome_mod_100001.txt | AC | 59 ms | 69900 KiB |
| palindrome_mod_2.txt | AC | 52 ms | 62136 KiB |
| palindrome_mod_200000.txt | AC | 62 ms | 75420 KiB |
| palindrome_mod_299999.txt | AC | 67 ms | 81580 KiB |
| palindrome_mod_3.txt | AC | 53 ms | 62304 KiB |
| palindrome_mod_300000.txt | AC | 67 ms | 81860 KiB |
| palindrome_mod_4.txt | AC | 43 ms | 62256 KiB |
| palindrome_mod_5.txt | AC | 46 ms | 62072 KiB |
| palindrome_mod_50001.txt | AC | 59 ms | 67536 KiB |
| random_1.txt | AC | 55 ms | 62172 KiB |
| random_10.txt | AC | 53 ms | 62140 KiB |
| random_100001.txt | AC | 62 ms | 71108 KiB |
| random_101.txt | AC | 51 ms | 62300 KiB |
| random_3000.txt | AC | 54 ms | 64812 KiB |
| random_300000.txt | AC | 70 ms | 82864 KiB |
| random_50001.txt | AC | 60 ms | 67948 KiB |
| sample_1.txt | AC | 51 ms | 62072 KiB |
| sample_2.txt | AC | 50 ms | 62172 KiB |
| sample_3.txt | AC | 53 ms | 62180 KiB |