SOSdp
layout: post
title: SOSdp
author: "luowentaoaa"
catalog: true
tags:
mathjax: true
- codeforces
- DP

i=0 pre=0000 nex=0001
i=0 pre=0010 nex=0011
i=0 pre=0100 nex=0101
i=0 pre=0110 nex=0111
i=0 pre=1000 nex=1001
i=0 pre=1010 nex=1011
i=0 pre=1100 nex=1101
i=0 pre=1110 nex=1111
i=1 pre=0000 nex=0010
i=1 pre=0001 nex=0011
i=1 pre=0100 nex=0110
i=1 pre=0101 nex=0111
i=1 pre=1000 nex=1010
i=1 pre=1001 nex=1011
i=1 pre=1100 nex=1110
i=1 pre=1101 nex=1111
i=2 pre=0000 nex=0100
i=2 pre=0001 nex=0101
i=2 pre=0010 nex=0110
i=2 pre=0011 nex=0111
i=2 pre=1000 nex=1100
i=2 pre=1001 nex=1101
i=2 pre=1010 nex=1110
i=2 pre=1011 nex=1111
i=3 pre=0000 nex=1000
i=3 pre=0001 nex=1001
i=3 pre=0010 nex=1010
i=3 pre=0011 nex=1011
i=3 pre=0100 nex=1100
i=3 pre=0101 nex=1101
i=3 pre=0110 nex=1110
i=3 pre=0111 nex=1111
i=0000
i=0001 0000
i=0010 0000
i=0011 0010 0001
i=0100 0000
i=0101 0100 0001
i=0110 0100 0010
i=0111 0110 0101 0011
i=1000 0000
i=1001 1000 0001
i=1010 1000 0010
i=1011 1010 1001 0011
i=1100 1000 0100
i=1101 1100 1001 0101
i=1110 1100 1010 0110
i=1111 1110 1101 1011 0111
Process returned 0 (0x0) execution time : 0.067 s
Press any key to continue.
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e6+50;
typedef long long ll;
const ll mod=1e9+7;
char s[maxn];
int dp[(1<<21)+50];
bool ok[(1<<21)+50];
int cal(int x){
if(x==0)return 0;
return x%2+cal(x/2);
}
vector<int>v[maxn];
int main(){
std::ios::sync_with_stdio(false);
for(int i=0;i<4;i++){
for(int j=0;j<(1<<4);j++){
if((j&(1<<i))==0){
bitset<4> a(j);
cout<<"i="<<i<<" pre="<<a<<" nex=";
a.set(i);
cout<<a.set(i)<<endl;
v[j|(1<<i)].push_back(j);
dp[j|(1<<i)]=max(dp[j|(1<<i)],dp[j]);
}
}
}
for(int i=0;i<(1<<4);i++){
bitset<4> a(i);
cout<<"i="<<a<<" ";
for(auto j:v[i]){
bitset<4> b(j);
cout<<b<<" ";
}
cout<<endl;
}
return 0;
}
SOSdp的更多相关文章
- 数位DP::SoSDP
数位DP:: SoSDP 学习博客(待补) 下面做一些例题: SPECIAL PAIRS 题意 给n个数字,求这些数字有多少对的\(AND\) 结果是0.数字不大于1e6.顺序反相反视为不同的对. 思 ...
- Codeforces 1009G Allowed Letters 最大流转最小割 sosdp
Allowed Letters 最直观的想法是贪心取, 然后网络流取check可不可行, 然后T了. 想到最大流可以等于最小割, 那么我们状压枚举字符代表的6个点连向汇点是否断掉, 然后再枚举64个本 ...
- CF 1400G.Mercenaries 题解【SOSDP 组合数学】
CF 1400G.Mercenaries 题意: 有\(n\)个佣兵,问雇佣至少一名雇佣兵且满足下述条件的方案数 如果雇佣第\(i\)个佣兵必须要求最终雇佣的总人数\(x\)满足\(l_i\le x\ ...
- Manthan, Codefest 19 (open for everyone, rated, Div. 1 + Div. 2) F. Bits And Pieces sosdp
F. Bits And Pieces 题面 You are given an array
- SOS--DP(基础版本)未压缩空间
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include <cstdio>//sprintf islower isupp ...
- Codeforces 279D The Minimum Number of Variables 状压dp
The Minimum Number of Variables 我们定义dp[ i ][ mask ]表示是否存在 处理完前 i 个a, b中存者 a存在的状态是mask 的情况. 然后用sosdp处 ...
- Educational Codeforces Round 48 (Rated for Div. 2)G. Appropriate Team
题意:求满足条件的(i,j)对数:\(gcd(v,a_i)=x,lcm(v,a_j)=y\) 题解:\(x|a_i,a_j|y\),\(x|y\),考虑质因子p,假设a_i中p次数为a,x中次数为b, ...
- Codeforces Round #257 (Div. 1) D - Jzzhu and Numbers 容斥原理 + SOS dp
D - Jzzhu and Numbers 这个容斥没想出来... 我好菜啊.. f[ S ] 表示若干个数 & 的值 & S == S得 方案数, 然后用这个去容斥. 求f[ S ] ...
- CF1208F Bits And Pieces
CF1208F Bits And Pieces 传送门 思路 这里要运用SOS-DP的思路(\(\text{Sum over Subsets}\)).我在另外一篇博客里介绍过,如有需要可以搜索一下我的 ...
随机推荐
- 2019.6.20 校内测试 NOIP模拟 Day 1 分析+题解
这次是zay神仙给我们出的NOIP模拟题,不得不说好难啊QwQ,又倒数了~ T1 大美江湖 这个题是一个简单的模拟题. ----zay 唯一的坑点就是打怪的时候计算向上取整时,如果用ceil函数一 ...
- Python基础之基本数据类型的总结
基本数据类型的总结 1. 按照存储空间的占用分(从低到高) 数字 字符串 集合:无序,即无序存索引相关信息 元组:有序,需要存索引相关信息,不可变 列表:有序,需要存索引相关信息,可变,需要处理数据的 ...
- CodeForces 754C Vladik and chat ——(xjbg)
虽然是xjbg的题目,但是并不很好做. 题意不难理解.读入有点麻烦.做法是先正着推每段对话的?可能是谁说的,然后反过来选择即可.正推时,其中vis数组表示谁已经被用过了,cnt表示该组当前可以选择几个 ...
- godaddy SSL证书不信任
在使用网上教程的部署godaddy证书,会出现证书不受信任的情况. 各别审核比较严格的浏览器会阻止或者要求添加例外.情况如下: 利用在线证书测试工具会提示根证书的内容为空.从而导致证书不受信任. 解决 ...
- DDCTF-2018-writeup(5misc)
打了好几天最后也只是80多名,我好菜啊.jpg 0x00 (╯°□°)╯︵ ┻━┻ 题目: (╯°□°)╯︵ ┻━┻ d4e8e1f4a0f7e1f3a0e6e1f3f4a1a0d4e8e5a0e6 ...
- Netfilter 之 钩子函数调用
本篇主要从三层协议栈调用函数NF_HOOK说起,不断深入,分析某个钩子点中所有钩子函数的调用流程,但是本文不包含规则介绍和核心的规则匹配流程,后续文章将继续分析: NF_HOOK函数先调用了nf_ho ...
- Nginx之编写HTTP模块
1. 常用数据结构 1.1 ngx_str_t typedef struct { /* * 字符串的有效长度 */ size_t len; /* * 有效字符串的起始地址,该字符串通常并不以'\0'结 ...
- TensorFlow错误ValueError: No gradients provided for any variable
使用TensorFlow训练神经网络的时候,出现以下报错信息: Traceback (most recent call last): File "gan.py", line 1 ...
- LeetCode 200. 岛屿的个数(Number of Islands)
题目描述 给定一个由 '1'(陆地)和 '0'(水)组成的的二维网格,计算岛屿的数量.一个岛被水包围,并且它是通过水平方向或垂直方向上相邻的陆地连接而成的.你可以假设网格的四个边均被水包围. 示例 1 ...
- koa 项目实战(六)注册接口加密
1.创建工具类 根目录/config/tools.js const bcrypt = require('bcryptjs'); const tools = { enbcrypt(password) { ...