11 2019 档案
摘要:题意:http://acm.hdu.edu.cn/showproblem.php?pid=4117 思路:https://blog.csdn.net/u013306830/article/details/77586562 主要就是卡你内存,AC自动机的字典树得要用了再清空。 代码有点长吧。。。 1
阅读全文
摘要:题意: 思路: 先建好整棵树。 遇到+val操作用dfn对区间+val 遇到加新点清空一下该点的点值(这里保证了之后查询的点肯定是清空过的) 差分+树状数组or线段树 1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include
阅读全文
摘要:1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc exit strcat itoa sys
阅读全文
摘要:让DAG变成强连通就是把尾和头连起来,也就是入度和出度为0的点,添的边数:max(num_in==0,num_out==0)
阅读全文
摘要:这才是更一般的二分写法--HDU5412 1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc
阅读全文
摘要:1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc exit strcat itoa sys
阅读全文
摘要:题意:https://ac.nowcoder.com/acm/contest/882/E 给你01矩阵,有两种操作:1是把一个位置0变1、1变0,2是问你从第一行i开始,到最后一行j有几种走法。你只能不能向上走而且不能往回走。 思路: 01矩阵里每一行可以用一个矩阵表示向下有几种走法,i行到j行的的
阅读全文
摘要:题意:https://codeforces.com/group/ikIh7rsWAl/contest/259944/problem/G 给你一颗树(可能有好几棵),你每次最多只能去掉k个叶子节点,问你最多几次能去完。 思路: 按深度deep保存每个深度的节点个数,从前往后for一遍,过程中如果一个d
阅读全文
摘要:题意:https://codeforces.com/group/ikIh7rsWAl/contest/259944/problem/D 给你q个操作,4个数n,a,k,c,从n好位置开始每次加a的位置变成字符c,加到k次停止。 思路: 首先肯定是从下往上修改,改完就可以不再考虑该位置了。 1.对于a
阅读全文
摘要:题意: 有n个数,每个数都有价钱,连续的取可以获得len*len的利益,使利益最大。 思路: 三维DP,1、2、3维分别是第i个,剩余多少钱,从后往前连续的有几个。 1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include
阅读全文
摘要:题意:http://acm.hdu.edu.cn/showproblem.php?pid=2594 如题。 思路: Next数组记录的是pos位置失配时要跑到哪里,所以最后得再添加一个字符‘#’。 连结两个串的中间加一些奇怪字符以保证next值不在同一个串中。 1 #define IOS ios_b
阅读全文
摘要:题意:http://acm.hdu.edu.cn/showproblem.php?pid=1695 直接上莫比乌斯模板。 1 #include <bits/stdc++.h> 2 using namespace std; 3 const long long maxn=100005; 4 5 long
阅读全文
摘要:题意:http://acm.hdu.edu.cn/showproblem.php?pid=2242 给你一个图,问你缩完点树上割边的做小绝对值差。 思路: 这题核算起来整整做了我一天(即24个小时)!!!一开始是MLE了近20发,然后TLE5、6发,再WA了一个晚上加一个下午。 有一种自闭是你突然对
阅读全文
摘要:题意:http://acm.hdu.edu.cn/showproblem.php?pid=2516 1堆石子有n个,两人轮流取.先取者第1次可以取任意多个,但不能全部取完.以后每次取的石子数不能超过上次取子数的2倍。取完者胜.先取者负输出"Second win".先取者胜输出"First win".
阅读全文
摘要:题意:http://acm.hdu.edu.cn/showproblem.php?pid=2458 问你二分图的最大团是多大。 1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf i
阅读全文
摘要:最大团 = 补图的最大独立集; 最大独立集 = 顶点数 - 最大匹配; 所以最大团 = 顶点数 - 补图的最大匹配数;
阅读全文
摘要:题意:https://www.nitacm.com/problem_show.php?pid=2266 vis记【x】【y】【dir】三个状态就行。 引用:https://blog.csdn.net/qq_37451344/article/details/80243077 1 #include<st
阅读全文
摘要:点覆盖集:无向图G的一个点集,使得该图中所有边都至少有一个端点在该点集中。 最小点权覆盖集:在带点权无向图G中,点权和最小的点覆盖集。 点独立集:无向图G的一个点集,使得任何两个在点集中的点在图G中都不相邻。 最大点权独立集:在无向带权图G中,点权和最大的点独立集。 最小点权覆盖集=最小割=最大流
阅读全文
摘要:题意:http://acm.hdu.edu.cn/showproblem.php?pid=1540 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); #include <cstdio>//sprintf islower isupper #in
阅读全文
摘要:1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc exit strcat itoa sys
阅读全文
摘要:1 #define IOS ios_base::sync_with_stdio(0); cin.tie(0); 2 #include <cstdio>//sprintf islower isupper 3 #include <cstdlib>//malloc exit strcat itoa sys
阅读全文
摘要:题意:http://codeforces.com/gym/102394/problem/E 1操作是给你一串数,2操作是连结两个串(所以可能很长),问你最后一个串的值(知道最多的个数就很好算,关键计算个数) 思路: 对二操作建图,一开始还以为建出来的是树就可以直接BFS计算次数,自闭了好久,最后才发
阅读全文
摘要:题意:http://codeforces.com/problemset/problem/915/C 举个例子:假使排好序后a字符串是123456,b是456456,按照上述方法遍历,213456 ->312456->412356->(这是第一个字符的最大值,再往下变的话只能是5了,但不满足题意)—–
阅读全文
摘要:题意:http://acm.hdu.edu.cn/showproblem.php?pid=2082
阅读全文
摘要:题意: 移动木头盘不能a到c,必须a到b到c。 问你移动次数。 假设将n层塔从A经B挪到C需要f[n]步。那么具体的移动过程可以这样看:将上面n-1层从A经B挪到C需要f[n-1]步,再将第n层从A挪到B,需要一步,再将上n-1层从C经B挪到A,需要f[n-1]步,再将第n层从B挪到C,需要一步,再
阅读全文