Submission #4791346


Source Code Expand

Copy
N = int(input())
N += 1
dp = []
for l in range(N):
  L = []
  for i in range(4):
    I = []
    for j in range(4):
      J = [0,0,0,0]
      I.append(J)
    L.append(I)
  dp.append(L)
dp[0][0][0][0] = 1
NGLIST_JKL = [[1,0,2],[1,1,2],[1,2,2],[1,3,2],[1,2,0],[1,2,1],[1,2,2],[1,2,3]]
NGLIST_KLM = [[1,2,3],[2,1,3],[1,3,2]]
for i in range(N-1):
  for j in range(4):
    for k in range(4):
      for l in range(4):
        if not [j,k,l] in NGLIST_JKL:
          for m in range(4):
            if not [k,l,m] in NGLIST_KLM:
              dp[i+1][k][l][m] += dp[i][j][k][l]
              dp[i+1][k][l][m] = dp[i+1][k][l][m]%(10**9+7)
        else:
          if j == 1 and l == 2:
            for m in range(4):
              if m != 3:
                dp[i+1][k][l][m] += dp[i][j][k][l]
                dp[i+1][k][l][m] = dp[i+1][k][l][m]%(10**9+7)
          elif j == 1 and k == 2:
            for m in range(4):
              if m != 3:
                dp[i+1][k][l][m] += dp[i][j][k][l]
                dp[i+1][k][l][m] = dp[i+1][k][l][m]%(10**9+7)
ans = 0
for i in range(4):
  for j in range(4):
    for k in range(4):
      ans += dp[N-1][i][j][k]%(10**9+7)
print(ans%(10**9+7))

Submission Info

Submission Time
Task D - We Like AGC
User Syuko4omi
Language Python3 (3.4.3)
Score 400
Code Size 1218 Byte
Status
Exec Time 48 ms
Memory 3444 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 a01, a02, a03
All 400 / 400 a01, a02, a03, b04, b05, b06, b07, b08, b09, b10, b11, b12, b13
Case Name Status Exec Time Memory
a01 19 ms 3192 KB
a02 19 ms 3192 KB
a03 48 ms 3316 KB
b04 20 ms 3192 KB
b05 20 ms 3192 KB
b06 21 ms 3192 KB
b07 23 ms 3192 KB
b08 26 ms 3192 KB
b09 33 ms 3192 KB
b10 46 ms 3316 KB
b11 47 ms 3316 KB
b12 46 ms 3316 KB
b13 46 ms 3444 KB