摘要:
主要是main()中的处理,接下来就是二分匹配的模板题了 阅读全文
摘要:
题目大意:原题链接 给出N个未编号的质量各不相同的球,以及它们质量轻重的大小关系,给它们从1~N贴标签编号,无重复。问是否存在可行的编号方法,不存在输出-1, 如果存在则输出唯一一种方案,此方案是使得编号小的球的重量尽量轻,先是编号为1的重量要最轻,其次比编号2,以此类推...... 思路:当解有多 阅读全文
摘要:
题目大意:给定一个字符串和一本字典,问至少需要删除多少个字符才能匹配到字典中的单词序列。PS:是单词序列,而不是一个单词 思路: 动态规划 主要是知道状态方程的含义: 令dp[i]表示从message中第i个字符开始,到第L个字符(结尾处)这段区间所删除的字符数,初始化为dp[L]=0 (dp[i] 阅读全文
摘要:
#include #include #include #include #define N (int)(1e7+5) using namespace std; int fa[N],va[N],lazy[N]; bool vis[N]; int n,u,v; long long sum; long long dfs(int i) { if(vis[i]) return 0;... 阅读全文
摘要:
#include #include #include #include #define maxn 40010 using namespace std; int indeg[maxn]; vector g[maxn]; int main() { int T,n,m; int u,v,w; scanf("%d",&T); while(T--){ sca... 阅读全文
摘要:
#include #include #include #define maxn 20005 using namespace std; struct Edge { int to; int next; }e[2*maxn]; int t,n,x,y,tot; int head[maxn],num[maxn],balance[maxn]; void Init() { tot=... 阅读全文
摘要:
1.查找:STL中关于二分查找的函数有三个lower_bound 、upper_bound 、binary_search 。这三个函数都运用于有序区间(当然这也是运用二分查找的前提),下面记录一下这两个函数。 ForwardIter lower_bound(ForwardIter first, Fo 阅读全文