Submission #1868470


Source Code Expand

import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍(右, 下, 左, 上)
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def solve(T):
    ans = 0

    n, q, next_c = 0, 0, 0
    for i, t in enumerate(T):
        if t == "2":
            if next_c == 0:
                n += 1
            else:
                n = 1
                if q > 0:
                    n += q - (q % 2 != 0)
            q = 0
            next_c = 1
        elif t == "5":
            if next_c == 1:
                n += 1
            else:
                if q > 0:
                    n = 1 + q - (q % 2 == 0)
                else:
                    n = 0
            q = 0
            next_c = 0
        elif t == "?":
            q += 1
            n += 1
            next_c = (next_c + 1) % 2
        else:
            n, q, next_c = 0, 0, 0

        if n % 2 == 0:
            ans = max(ans, n)

    return ans


def main():
    T = input()
    print(solve(T))

if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task B - ニコニコレベル
User MitI_7
Language Python (3.4.3)
Score 300
Code Size 1489 Byte
Status AC
Exec Time 69 ms
Memory 4212 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 5
AC × 22
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt
All sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, large_01.txt, large_02.txt, large_03.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt, sample_05.txt
Case Name Status Exec Time Memory
hand_01.txt AC 36 ms 4212 KB
hand_02.txt AC 26 ms 3956 KB
hand_03.txt AC 26 ms 3952 KB
hand_04.txt AC 30 ms 3952 KB
hand_05.txt AC 67 ms 4084 KB
large_01.txt AC 63 ms 4084 KB
large_02.txt AC 66 ms 4084 KB
large_03.txt AC 64 ms 4080 KB
random_01.txt AC 63 ms 4080 KB
random_02.txt AC 69 ms 4088 KB
random_03.txt AC 69 ms 4088 KB
random_04.txt AC 62 ms 4080 KB
sample_01.txt AC 26 ms 3956 KB
sample_02.txt AC 26 ms 3956 KB
sample_03.txt AC 26 ms 3960 KB
sample_04.txt AC 26 ms 3952 KB
sample_05.txt AC 26 ms 3952 KB