## 「SCOI2007」排列-状压dp

·  ✏️ About  371 words  ·  ☕ 1 mins read · 👀... views

Luogu P4163

## 题解

$$dp[S][r] = \sum dp[S | 2^i][r*10 + s[i]],\text{if } S & 2^i = 0$$

$\text{dfs}$ 即可，时间复杂度为 $O(n2^n \times d)$，事实上跑不满…

## 代码

  1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52  #include #include using namespace std; const int MAXN = 11; char str[MAXN];int n,d; int dp[1<

WRITTEN BY
cqqqwq
A student in Computer Science.