結果
| 問題 | No.1811 EQUIV Ten |
| コンテスト | |
| ユーザー |
lam6er
|
| 提出日時 | 2025-03-20 20:35:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 531 ms / 2,000 ms |
| コード長 | 1,015 bytes |
| コンパイル時間 | 138 ms |
| コンパイル使用メモリ | 82,752 KB |
| 実行使用メモリ | 230,080 KB |
| 最終ジャッジ日時 | 2025-03-20 20:37:32 |
| 合計ジャッジ時間 | 6,386 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 33 |
ソースコード
MOD = 10**9 + 7
N = int(input())
if N < 4:
print(0)
else:
# dp[i][mask][flag] is the count at step i, with the last 3 bits as mask, flag indicating if pattern found
dp = [[[0] * 2 for _ in range(8)] for _ in range(N + 1)]
dp[0][0][0] = 1
for i in range(N):
for mask in range(8):
for flag in [0, 1]:
current = dp[i][mask][flag]
if current == 0:
continue
for b in [0, 1]:
new_mask = ((mask << 1) | b) & 0b111
new_flag = flag
# Check if current mask and b form the pattern '1010' (10 in decimal)
if ((mask << 1) | b) == 0b1010:
new_flag = 1
dp[i+1][new_mask][new_flag] = (dp[i+1][new_mask][new_flag] + current) % MOD
# Sum all cases where flag is 1 after processing all bits
total = 0
for mask in range(8):
total = (total + dp[N][mask][1]) % MOD
print(total)
lam6er