結果

問題 No.1811 EQUIV Ten
ユーザー customaddonecustomaddone
提出日時 2022-01-14 23:13:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 2,249 bytes
コンパイル時間 918 ms
コンパイル使用メモリ 87,700 KB
実行使用メモリ 138,372 KB
最終ジャッジ日時 2023-08-12 22:06:06
合計ジャッジ時間 9,265 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
73,252 KB
testcase_01 AC 109 ms
73,264 KB
testcase_02 AC 123 ms
78,864 KB
testcase_03 AC 111 ms
73,116 KB
testcase_04 AC 110 ms
72,968 KB
testcase_05 AC 110 ms
73,272 KB
testcase_06 AC 111 ms
73,356 KB
testcase_07 AC 111 ms
73,400 KB
testcase_08 AC 111 ms
72,960 KB
testcase_09 AC 112 ms
73,464 KB
testcase_10 AC 112 ms
73,276 KB
testcase_11 AC 371 ms
128,412 KB
testcase_12 AC 384 ms
132,192 KB
testcase_13 AC 409 ms
136,864 KB
testcase_14 AC 416 ms
138,044 KB
testcase_15 AC 412 ms
138,372 KB
testcase_16 AC 111 ms
73,264 KB
testcase_17 AC 128 ms
78,640 KB
testcase_18 AC 128 ms
78,812 KB
testcase_19 AC 119 ms
78,616 KB
testcase_20 AC 146 ms
81,908 KB
testcase_21 AC 145 ms
81,572 KB
testcase_22 AC 128 ms
78,648 KB
testcase_23 AC 225 ms
99,300 KB
testcase_24 AC 154 ms
82,704 KB
testcase_25 AC 127 ms
78,652 KB
testcase_26 AC 211 ms
95,504 KB
testcase_27 AC 140 ms
80,172 KB
testcase_28 AC 110 ms
73,356 KB
testcase_29 AC 120 ms
78,588 KB
testcase_30 AC 361 ms
127,176 KB
testcase_31 AC 140 ms
80,704 KB
testcase_32 AC 154 ms
82,884 KB
testcase_33 AC 157 ms
82,832 KB
testcase_34 AC 345 ms
124,356 KB
testcase_35 AC 209 ms
95,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict, deque, Counter
from heapq import heapify, heappop, heappush
import math
from copy import deepcopy
from itertools import combinations, permutations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right

import sys

def input():
    return sys.stdin.readline().rstrip()
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getListGraph():
    return list(map(lambda x:int(x) - 1, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]

mod = 10 ** 9 + 7
MOD = 998244353
# sys.setrecursionlimit(10000000)
inf = float('inf')
eps = 10 ** (-15)
dy = [0, 1, 0, -1]
dx = [1, 0, -1, 0]

#############
# Main Code #
#############

"""
Nがくそでか bitで考える 桁dp?
x // 2^k あるbit以下を切り捨て 後ろ4つが 1010
つまり 1010を持つ数がいくつあるか 桁dp
'', '1', '10', '101', '1010' の5つ
耳桁dp
"""

S = '1' * getN()
if S == '':
    print(0)
    exit()

N = len(S)
# 次にあるべき数字
jud = [1, 0, 1, 0, inf]
# dp[i][j][k]: iまで進んで最大値になる可能性がある(0)/ない(1), 状態はk
dp = [[[0] * 5 for _ in range(2)] for i in range(N + 1)]
dp[0][0][0] = 1

for i in range(N):
    d = int(S[i])
    # Lになる可能性があるかないか
    # ある→ある
    for j in range(2):
        # 次の桁は何にする あるの場合はd以下 ないの場合は0, 1
        for d_j in range(2 if j else d + 1):
            # 状態1~4
            for k in range(4):
                # 次に進める
                if d_j == jud[k]:
                    dp[i + 1][j | (d_j < d)][k + 1] += dp[i][j][k]
                    dp[i + 1][j | (d_j < d)][k + 1] %= mod
                # 進めない
                else:
                    # 次が0なら状態0, 1なら状態1
                    dp[i + 1][j | (d_j < d)][(d_j == 1)] += dp[i][j][k]
                    dp[i + 1][j | (d_j < d)][(d_j == 1)] %= mod
            # 状態5
            dp[i + 1][j | (d_j < d)][4] += dp[i][j][4]
            dp[i + 1][j | (d_j < d)][4] %= mod

print((dp[i + 1][0][-1] + dp[i + 1][1][-1]) % mod)
0