题目链接:https://codeforces.com/contest/1242/problem/C
具体做法参照题解,记录一个子集当中dp的方法
https://cp-algorithms.com/algebra/all-submasks.html
代码:
#include
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair pii;
const int MAXN=5005;
const int MAXM=(1<<15)+5;
ll sum[20];
bool vis[MAXN*15],ok[MAXM];
int x[16][MAXN],n[20],num[MAXN*15],pos[MAXN*15],stk[MAXN*15],dp[MAXM],pre[MAXM],l[16],r[16];
int top=0;
map id;
vector E[MAXN*15],sv[MAXM];
void dfs(int now,int st)
{
if(vis[now])
{
int cir=0;
for(int i=top;i>=1;i--)
{
cir|=(1<=1;i--)
{
sv[cir].pb(stk[i]);
if(stk[i]==now) break;
}
}
return ;
}
if(st&(1<