SOS问题
Posted guaguastandup
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SOS问题相关的知识,希望对你有一定的参考价值。
SOS问题
模板
//iterative version
for(int mask = 0; mask < (1<<N); ++mask){
dp[mask][-1] = A[mask];
//handle base case separately (leaf states)
for(int i = 0;i < N; ++i){
if(mask & (1<<i))
dp[mask][i] = dp[mask][i-1] + dp[mask^(1<<i)][i-1];
else
dp[mask][i] = dp[mask][i-1];
}
F[mask] = dp[mask][N-1];
}
//memory optimized, super easy to code.
for(int i = 0; i<(1<<N); ++i)
F[i] = A[i];
for(int i = 0;i < N; ++i) for(int mask = 0; mask < (1<<N); ++mask){
if(mask & (1<<i))
F[mask] += F[mask^(1<<i)];
}
S(mask,i) 表示第0位到第i位不同的子集
时间复杂度(O(N2^N))
tutorial
https://codeforces.com/blog/entry/45223
https://blog.csdn.net/weixin_38686780/article/details/100109753
例题
Practice Problems
I hope you enjoyed it. Following are some problems built on SOS.
-
https://blog.csdn.net/tianyizhicheng/article/details/100392870
-
Pepsi Cola(resembles above discussion problem). Need to join this group.
-
Uchiha and Two Products(resembles above discussion problem)
-
Strange Functions(Same as above discussion problem)
EDIT: Practice problems are now arranged in almost increasing order of difficulty.
以上是关于SOS问题的主要内容,如果未能解决你的问题,请参考以下文章
详细说说在Vistual studio IDE里使用SOS.dll扩展调试程序