Submission #1868437


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 main():
    T = input()
    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 += q - (q % 2 == 0)
                else:
                    n = 0
            q = 0
            next_c = 0
        elif t == "?":
            q += 1
            n += 1
        else:
            n, q, next_c = 0, 0, 0

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

    print(ans)

if __name__ == '__main__':
    main()

Submission Info

Submission Time
Task B - ニコニコレベル
User MitI_7
Language Python (3.4.3)
Score 0
Code Size 1407 Byte
Status WA
Exec Time 65 ms
Memory 4080 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 300
Status
AC × 5
AC × 14
WA × 8
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 26 ms 3944 KB
hand_02.txt AC 26 ms 3944 KB
hand_03.txt AC 26 ms 3948 KB
hand_04.txt WA 26 ms 3948 KB
hand_05.txt AC 60 ms 4076 KB
large_01.txt WA 60 ms 4080 KB
large_02.txt WA 60 ms 4076 KB
large_03.txt WA 61 ms 4076 KB
random_01.txt WA 60 ms 4076 KB
random_02.txt WA 65 ms 4076 KB
random_03.txt WA 61 ms 4076 KB
random_04.txt WA 62 ms 4076 KB
sample_01.txt AC 26 ms 3952 KB
sample_02.txt AC 26 ms 3944 KB
sample_03.txt AC 26 ms 3944 KB
sample_04.txt AC 26 ms 3952 KB
sample_05.txt AC 26 ms 3944 KB