結果

問題 No.220 世界のなんとか2
ユーザー mattu34mattu34
提出日時 2023-12-22 09:10:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 160 ms / 1,000 ms
コード長 1,923 bytes
コンパイル時間 162 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 88,336 KB
最終ジャッジ日時 2023-12-22 09:10:15
合計ジャッジ時間 4,130 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 155 ms
87,568 KB
testcase_01 AC 151 ms
87,568 KB
testcase_02 AC 153 ms
87,568 KB
testcase_03 AC 151 ms
87,568 KB
testcase_04 AC 151 ms
87,568 KB
testcase_05 AC 151 ms
87,568 KB
testcase_06 AC 151 ms
87,568 KB
testcase_07 AC 153 ms
87,568 KB
testcase_08 AC 149 ms
87,568 KB
testcase_09 AC 154 ms
87,568 KB
testcase_10 AC 151 ms
87,568 KB
testcase_11 AC 150 ms
87,568 KB
testcase_12 AC 151 ms
87,568 KB
testcase_13 AC 151 ms
87,568 KB
testcase_14 AC 150 ms
87,568 KB
testcase_15 AC 151 ms
87,568 KB
testcase_16 AC 150 ms
87,568 KB
testcase_17 AC 160 ms
88,336 KB
testcase_18 AC 159 ms
88,336 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import *
import sys
import heapq
import bisect
import itertools
from functools import lru_cache
from types import GeneratorType
from fractions import Fraction
import math
import copy

# sys.setrecursionlimit(int(1e7))
# @lru_cache(maxsize=None) # CPython特化
# @bootstrap # PyPy特化(こっちのほうが速い) yield dfs(), yield Noneを忘れずに


def bootstrap(f, stack=[]):  # yield
    def wrappedfunc(*args, **kwargs):
        if stack:
            return f(*args, **kwargs)
        else:
            to = f(*args, **kwargs)
            while True:
                if type(to) is GeneratorType:
                    stack.append(to)
                    to = next(to)
                else:
                    stack.pop()
                    if not stack:
                        break
                    to = stack[-1].send(to)
            return to

    return wrappedfunc


dxdy1 = ((0, 1), (0, -1), (1, 0), (-1, 0))  # 上下左右
dxdy2 = ((0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (-1, -1), (1, -1), (-1, 1))  # 8方向すべて
dxdy3 = ((0, 1), (1, 0))  # 右 or 下
dxdy4 = ((1, 1), (1, -1), (-1, 1), (-1, -1))  # 斜め
INF = float("inf")
MOD = 998244353
mod = 998244353
MOD2 = 10**9 + 7
mod2 = 10**9 + 7
# memo : len([a,b,...,z])==26
# memo : 2^20 >= 10^6
# 小数の計算を避ける : x/y -> (x*big)//y  ex:big=10**9

input = lambda: sys.stdin.readline().rstrip()
mi = lambda: map(int, input().split())
li = lambda: list(mi())
ii = lambda: int(input())
py = lambda: print("Yes")
pn = lambda: print("No")
pf = lambda: print("First")
ps = lambda: print("Second")

P = ii()
dp = [[[0] * 2 for _ in range(3)] for _ in range(P + 1)]
dp[0][0][0] = 1
for i in range(P):
    for j in range(3):
        for k in range(10):
            for m in range(2):
                dp[i + 1][(j + k) % 3][m | (k == 3)] += dp[i][j][m]
print(dp[-1][0][0] + dp[-1][1][1] + dp[-1][2][1] + dp[-1][0][1] - 1)
0