212482026-01-12 17:27:08algoproJárdakövezés háromféle elemmelpypy3Wrong answer 0/30128ms32000 KiB
# UUID: 6b94bd99-ddae-4f1e-8386-d754d9c1db34
import sys
sys.setrecursionlimit(10**7)

MOD = 2023
N = int(sys.stdin.readline())

dp = [[0]*4 for _ in range(N+1)]
dp[0][0] = 1


def fill_col(row, cur_mask, next_mask, col, val):
    if row == 2:
        dp[col + 1][next_mask] = (dp[col + 1][next_mask] + val) % MOD
        return

    if cur_mask & (1 << row):
        fill_col(row + 1, cur_mask, next_mask, col, val)
        return

    fill_col(row + 1, cur_mask | (1 << row), next_mask, col, val)

    if row == 0 and not (cur_mask & 2):
        fill_col(2, cur_mask | 3, next_mask, col, val)


    fill_col(row + 1, cur_mask | (1 << row), next_mask | (1 << row), col, val)

    if row == 0 and not (cur_mask & 2):
        fill_col(2, cur_mask | 3, next_mask | 1, col, val)
        fill_col(2, cur_mask | 3, next_mask | 2, col, val)


for i in range(N):
    for mask in range(4):
        val = dp[i][mask]
        if val:
            fill_col(0, mask, 0, i, val)

print(dp[N][0] % MOD)
SubtaskSumTestVerdictTimeMemory
base0/30
1Wrong answer0/043ms19652 KiB
2Wrong answer0/043ms19676 KiB
3Wrong answer0/239ms19636 KiB
4Wrong answer0/239ms19692 KiB
5Wrong answer0/245ms19684 KiB
6Wrong answer0/245ms19600 KiB
7Wrong answer0/241ms19832 KiB
8Wrong answer0/241ms20008 KiB
9Time limit exceeded0/2108ms26748 KiB
10Time limit exceeded0/2108ms26604 KiB
11Time limit exceeded0/2111ms29900 KiB
12Time limit exceeded0/3128ms31500 KiB
13Wrong answer0/397ms24164 KiB
14Wrong answer0/398ms24840 KiB
15Runtime error0/367ms32000 KiB