結果
| 問題 |
No.122 傾向と対策:門松列(その3)
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-04-23 21:59:37 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,094 ms / 5,000 ms |
| コード長 | 750 bytes |
| コンパイル時間 | 200 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 44,372 KB |
| 最終ジャッジ日時 | 2024-10-14 00:40:57 |
| 合計ジャッジ時間 | 11,756 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 8 |
ソースコード
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import itertools
import numpy as np
MOD = 10 ** 9 + 7
m = map(int, read().split())
L, R = zip(*zip(m, m))
def solve(perm):
U = 2 * 10 ** 4 + 10
dp = np.zeros(U, np.int64)
dp[0] = 1
for i in range(7):
j = perm.index(i)
lo = L[j]
hi = R[j]
newdp = np.empty(U, np.int64)
newdp[1:] = np.cumsum(dp[:-1])
dp = newdp
dp[:lo] = 0
dp[hi + 1:] = 0
dp %= MOD
return dp.sum() % MOD
answer = 0
for p in itertools.permutations(range(7)):
if min(p[1::2]) > max(p[::2]) or min(p[::2]) > max(p[1::2]):
answer += solve(p)
print(answer % MOD)
maspy