Submission #18579158


Source Code Expand

Copy
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def from_read(dtype=np.int64):
    return np.fromstring(read().decode(), dtype=dtype, sep=' ')


def from_readline(dtype=np.int64):
    return np.fromstring(readline().decode(), dtype=dtype, sep=' ')

def main(T):
    ans = 0
    ok_0 = np.all(T[::3] == 1) and np.all(T[1::3] == 1) and np.all(
        T[2::3] == 0)
    ok_1 = np.all(T[::3] == 1) and np.all(T[1::3] == 0) and np.all(
        T[2::3] == 1)
    ok_2 = np.all(T[::3] == 0) and np.all(T[1::3] == 1) and np.all(
        T[2::3] == 1)
    N = 10**10
    L = len(T)
    if ok_0:
        # 3n 文字目始まり。
        # 0<=3n かつ 3n + L <= 3*N
        ans += (3 * N - L) // 3 + 1
    if ok_1:
        ans += (3 * N - L - 1) // 3 + 1
    if ok_2:
        ans += (3 * N - L - 2) // 3 + 1
    return ans

N = int(readline())
T = np.array(list(read().rstrip()), np.int64)- ord('0')

print(main(T))

Submission Info

Submission Time
Task B - Many 110
User maspy
Language Python (3.8.2)
Score 400
Code Size 1034 Byte
Status AC
Exec Time 125 ms
Memory 29856 KB

Judge Result

Set Name All Sample
Score / Max Score 400 / 400 0 / 0
Status
AC × 32
AC × 2
Set Name Test Cases
All sample_01.txt, sample_02.txt, testcase_1.txt, testcase_10.txt, testcase_11.txt, testcase_12.txt, testcase_13.txt, testcase_14.txt, testcase_15.txt, testcase_16.txt, testcase_17.txt, testcase_18.txt, testcase_19.txt, testcase_2.txt, testcase_20.txt, testcase_21.txt, testcase_22.txt, testcase_23.txt, testcase_24.txt, testcase_25.txt, testcase_26.txt, testcase_27.txt, testcase_28.txt, testcase_29.txt, testcase_3.txt, testcase_30.txt, testcase_4.txt, testcase_5.txt, testcase_6.txt, testcase_7.txt, testcase_8.txt, testcase_9.txt
Sample sample_01.txt, sample_02.txt
Case Name Status Exec Time Memory
sample_01.txt AC 113 ms 27076 KB
sample_02.txt AC 108 ms 26956 KB
testcase_1.txt AC 103 ms 26656 KB
testcase_10.txt AC 105 ms 27064 KB
testcase_11.txt AC 106 ms 27080 KB
testcase_12.txt AC 106 ms 26956 KB
testcase_13.txt AC 106 ms 26952 KB
testcase_14.txt AC 107 ms 26984 KB
testcase_15.txt AC 125 ms 29544 KB
testcase_16.txt AC 120 ms 29856 KB
testcase_17.txt AC 121 ms 29632 KB
testcase_18.txt AC 115 ms 27856 KB
testcase_19.txt AC 110 ms 27872 KB
testcase_2.txt AC 106 ms 27096 KB
testcase_20.txt AC 107 ms 27592 KB
testcase_21.txt AC 118 ms 28836 KB
testcase_22.txt AC 113 ms 28256 KB
testcase_23.txt AC 107 ms 27160 KB
testcase_24.txt AC 121 ms 29268 KB
testcase_25.txt AC 117 ms 29056 KB
testcase_26.txt AC 122 ms 29096 KB
testcase_27.txt AC 120 ms 29012 KB
testcase_28.txt AC 108 ms 27680 KB
testcase_29.txt AC 108 ms 27096 KB
testcase_3.txt AC 106 ms 27252 KB
testcase_30.txt AC 108 ms 27296 KB
testcase_4.txt AC 109 ms 26952 KB
testcase_5.txt AC 106 ms 26980 KB
testcase_6.txt AC 107 ms 26984 KB
testcase_7.txt AC 105 ms 26648 KB
testcase_8.txt AC 107 ms 26952 KB
testcase_9.txt AC 106 ms 26952 KB