結果

問題 No.1811 EQUIV Ten
ユーザー customaddonecustomaddone
提出日時 2022-01-14 23:12:04
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 2,212 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 82,876 KB
実行使用メモリ 136,540 KB
最終ジャッジ日時 2024-04-30 17:06:14
合計ジャッジ時間 6,078 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
61,752 KB
testcase_01 AC 52 ms
62,244 KB
testcase_02 AC 62 ms
67,176 KB
testcase_03 RE -
testcase_04 AC 53 ms
63,364 KB
testcase_05 AC 52 ms
62,040 KB
testcase_06 AC 53 ms
62,212 KB
testcase_07 AC 54 ms
61,752 KB
testcase_08 AC 52 ms
61,556 KB
testcase_09 AC 54 ms
62,636 KB
testcase_10 AC 54 ms
62,568 KB
testcase_11 AC 340 ms
126,872 KB
testcase_12 AC 353 ms
130,352 KB
testcase_13 AC 382 ms
135,204 KB
testcase_14 AC 387 ms
136,540 KB
testcase_15 AC 389 ms
136,472 KB
testcase_16 AC 53 ms
61,888 KB
testcase_17 AC 69 ms
70,360 KB
testcase_18 AC 73 ms
72,720 KB
testcase_19 AC 64 ms
68,660 KB
testcase_20 AC 94 ms
80,384 KB
testcase_21 AC 94 ms
79,792 KB
testcase_22 AC 71 ms
71,992 KB
testcase_23 AC 187 ms
97,720 KB
testcase_24 AC 101 ms
81,124 KB
testcase_25 AC 72 ms
72,072 KB
testcase_26 AC 163 ms
93,876 KB
testcase_27 AC 88 ms
78,200 KB
testcase_28 AC 53 ms
63,020 KB
testcase_29 AC 63 ms
68,848 KB
testcase_30 AC 331 ms
125,176 KB
testcase_31 AC 90 ms
78,928 KB
testcase_32 AC 105 ms
81,164 KB
testcase_33 AC 105 ms
81,192 KB
testcase_34 AC 315 ms
122,808 KB
testcase_35 AC 163 ms
93,260 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()
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