![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
稍难
文章平均质量分 76
ccyy-
这个作者很懒,什么都没留下…
展开
-
hdu 2768 二分图匹配(难想到)
题意:有v个观众,每个人投给自己喜欢的猫(或者狗)和讨厌的狗(或者猫),如果出现喜欢的和别人讨厌的相同,则其中一人会不满意。 现要求得是最大满意的观众是多少。 方法:根据出现矛盾的两个观众序号建边。现在选择最多的顶点,要求各个顶点之间没有线相连,即不出现矛盾。就是求最大独立集。 最大匹配:二分图G中,找出边数最大的子图M,使得M中各条边均无公共顶点,则M为最大匹配。可用匈牙利算法求得。转载 2015-10-02 23:58:09 · 442 阅读 · 0 评论 -
poj 1386 Play on Words(欧拉通路)
Some of the secret doors contain a very interesting word puzzle. The team of archaeologists has to solve it to open that doors. Because there is no other way to open the doors, the puzzle is very impo原创 2015-08-20 23:12:47 · 410 阅读 · 0 评论 -
【codechef】Singal Pipes(DFS求期望)
https://www.codechef.com/IOPC2015/problems/IOPC15L#include using namespace std; #define sd(x) scanf("%d",&x) vector graph[200];int parents[200];double color[200][200]; void DFS(int root,i原创 2015-09-03 20:17:34 · 381 阅读 · 0 评论 -
【codechef】Devu and his Class(巧妙的 模拟,分类讨论)
Devu is a class teacher of a class of n students. One day, in the morning prayer of the school, all the students of his class were standing in a line. You are given information of their arrangement by原创 2015-04-11 17:42:48 · 711 阅读 · 0 评论 -
CERC2014 Can't stop playing(一维2048)
https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=4943注意点蛮多的。。。数列大小一定是先上升后下降的,也就是“^”形状。所以可以分成左右两部分s1,s2#include #include #include #include原创 2015-09-04 13:51:03 · 822 阅读 · 0 评论 -
zoj3738 Buy the Pets(人、猫、狗 DP)
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5120dp[i][j]表示取到第i个人第j种状态时的方案数。不过……为什么只能取#include using namespace std;bool x[45][45];long long dp[2][1<<21]; int n,m,p,q;int main(原创 2015-09-07 00:05:07 · 642 阅读 · 0 评论 -
swerc2014 Book Club(二分图匹配)
Porto’s book club is buzzing with excitement for the annual book exchange event! Every year, members bring their favorite book and try to find another book they like that is owned by someone willing t...原创 2015-09-02 10:02:02 · 1048 阅读 · 2 评论 -
swerc2014 GREAT + SWERC = PORTO(dfs,注意姿势)
We want to have a great SWERC at Porto this year and we approached this challenge in several ways. We even framed it as a word addition problem, similar to the classic SEND+MORE=MONEY, where each lett原创 2015-08-31 20:42:49 · 1071 阅读 · 0 评论 -
Dhaka2014 I Volume of Revolution (积分求体积)
英语又跪了……意思是给你一个曲线的方程(a平头椎台的体积计算公式:V = 1/3*h*(S1+S2*sqrt(S1*S2)曲线体积积分:∫(下a上b) π*f(x)*f(x)dx#include#define pi 3.1415926535using namespace std;double x[10],y[105],z[210];int main(){原创 2015-08-29 19:17:59 · 754 阅读 · 0 评论 -
Tokyo2014 There is No Alternative (最小生成树,灵活题)
Input Output Sample Input4 41 2 31 3 2 3 32 4 3Sample Output1 3给出一个图,求所有最小生成树的可能情况都会加进去的边的个数和总和。逆向思维。由于这条边在所有最小生成树中必会出现,所以,如果删除这条边,那么最小生成树的值就肯定会发生变化。原创 2015-08-30 21:37:26 · 441 阅读 · 0 评论 -
hznu 1437: Clockwise(隐藏的暴力水题,数学)
Saya have a long necklace with N beads, and she signs the beads from 1 to N. Then she fixes them to the wall to show N-1 vectors – vector i starts from bead i and end up with bead i+1.One day, Kud原创 2015-05-24 12:48:28 · 556 阅读 · 0 评论 -
hznu 1443 Ivan comes again!(set.lower_bound())
The Fairy Ivan gave Saya three problems to solve (Problem F). After Saya finished the first problem (Problem H), here comes the second. This is the enhanced version of Problem H. There i原创 2015-05-21 15:22:59 · 474 阅读 · 0 评论 -
poj 2786 Keep the Customer Satisfied(贪心+优先队列)
InputThe first line contains the number n of orders (n can be as large as 800000 for some test cases). It is followed by n lines. Each of which describes an order made of two integer values: the a原创 2015-06-07 18:27:32 · 543 阅读 · 0 评论 -
矩阵链乘法,添加括号
给定n个矩阵{A1,A2,…,An},其中Ai与Ai+1是可乘的,i=1,2 ,…,n-1。如何确定计算矩阵连乘积的计算次序,使得依此次序计算矩阵连乘积需要的数乘次数最少。 Input有N个矩阵连乘,用一行有n+1个数数组表示,表示是n个矩阵的行及第n个矩阵的列,它们之间用空格隔开. Output你的输出应该有C行,即每组测试数据的输出占一行,它是计算出的矩原创 2015-06-28 09:59:01 · 2039 阅读 · 0 评论 -
【codechef】Lazy Players
Concerned with the fitness levels of the players in the National Team, the coach decides to carry out a running drill in the next training session. So, he sets up checkpoints in the training ground at原创 2015-04-30 22:03:59 · 454 阅读 · 0 评论 -
fzu 2188 过河I(有难度的剪枝)
转自:http://www.cnblogs.com/jeff-wgc/p/4449319.htmlhttp://acm.fzu.edu.cn/problem.php?pid=2188过河ITime Limit:3000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uSubmit Status Prac转载 2015-10-06 18:53:29 · 408 阅读 · 0 评论 -
hdu5399 Too Simple(推论,分类讨论)
http://acm.hdu.edu.cn/showproblem.php?pid=5399题解:http://blog.csdn.net/queuelovestack/article/details/47753497#include#include#include#include#include#include#include#include#include#inc转载 2015-11-06 11:16:49 · 339 阅读 · 0 评论 -
【codechef】每次将l-r修剪成一样高度,求最少修剪几次
Example Input433 1 32 1 271 3 4 5 1 2 31 2 1 2 1 1 132 3 92 3 921 22 1Example Output230-1这题一看和涂色问题很像。但后来我发现两者是有区别的。涂色可以任意覆盖,而修剪只能越剪越短,不可能再变长。并且数据范围有10^5,肯定不是像涂色问题一样用区间dp。所以我后来用双端队列来维...原创 2018-04-18 14:38:05 · 246 阅读 · 0 评论 -
HUST - 1608 求带权有向图上的最长路
If you have a date with a pretty girl in a hurry, you can ignore what I will say next. Hellis is a little bad guy in Rural Small Technical College. And the most important fact is that he is espe原创 2017-04-02 18:59:37 · 762 阅读 · 0 评论 -
CF432D 求等于原串前缀的后缀子串,输出子串的长度和出现次数
给一个字符串,求等于原串前缀的后缀子串,输出子串的长度和出现次数。再普及一下后缀数组的height:http://www.mamicode.com/info-detail-1068381.html#include#define ll long long#define inf 0x7fffffff#define mod 1000000007using namespace std;原创 2017-03-21 01:57:35 · 635 阅读 · 0 评论 -
hdu4190 n个城市,m个投票箱。求票数最大的投票箱内票数最少时的数目
样例输入:2 72000005000004 612026803400200-1 -1样例输出:1000001700有n个城市,m个投票箱。每个城市的人口分别是xi。求票数最大的投票箱内票数最少时的数目。思路:尽量均分。【二分版】#include #include #include #include #include #原创 2016-04-17 16:08:38 · 709 阅读 · 0 评论 -
ZOJ 3790 Consecutive Blocks 最多删k个数求最长连续相同序列长度
题解:http://blog.csdn.net/csuhoward/article/details/38366737#include using namespace std; struct node{ int a,b,c,e; node(int aa=0,int bb=0,int cc=0,int ee=0){ a=aa;b=bb;c原创 2016-03-23 19:18:11 · 618 阅读 · 0 评论 -
ZOJ3805 Machine I型和L型的管道最少多宽?(贪心)
输入的x[i]代表有管道从i点接到x[i]点。注意整个图其实是个变相的倒树,并且需要灵活运用【The same code will be appeared at most twice】这句话联想到其实还是棵二叉树。由于管道可以无限长,所以某个节点向上延伸的左右子节点可以错开不在同一行,但是别忘了管道本身也占了一单位宽。#include #define ll long longusin原创 2016-03-23 23:28:17 · 435 阅读 · 0 评论 -
hdu5489(删除一段后的最长上升子序列长度)LIS
#includeusing namespace std;const int maxn = 1e5+5;int a[maxn];int g[maxn];int f[maxn];int h[maxn];int c[maxn]; int d[maxn]; const int INF = 0x3f3f3f3f;//#define LOCALint main(){#ifdef原创 2015-10-01 10:17:49 · 1146 阅读 · 0 评论 -
zoj3620 限定时间内从a点到b点的收益最大值(状压+搜索)
注意到了ed点后仍能把剩余时间用在继续访问其他点。所以不能标记某个点是否访问过(因为可能要折回),而是用某种状态+出点标记。#include #include #include #include #include #include #include #includeusing namespace std;struct node{ int a,b,c; node(int a原创 2016-03-19 01:06:20 · 511 阅读 · 0 评论 -
hdu4982 是否存在k个数和为n并且存在其中k-1个数和为完全平方数的情况
k个数必须是各不相同的。这题属于思维错误题。http://acm.hdu.edu.cn/showproblem.php?pid=4982#include #include #include #include #include #include #include #include #include #define ll long long usin原创 2016-02-01 22:04:28 · 627 阅读 · 0 评论 -
ACM-ICPC 2015 Asia Tsukuba Regional Online Open Contest B(两挡板之间放着圆球,求挡板最短距离)
一开始想得很麻烦,然后发现又读漏了可以简化题目的信息……好不容易想到的方法一定要记录一下。。。#include #include #include #include//ll dx[4]={0,0,-1,1};ll dy[4]={-1,1,0,0}; #include// #include #include #include #include #include原创 2015-11-30 12:00:28 · 770 阅读 · 0 评论 -
【编程之美挑战赛】回文字符序列(区间dp)
给定字符串,求它的回文子序列个数。回文子序列反转字符顺序后仍然与原序列相同。例如字符串aba中,回文子序列为"a", "a", "aa", "b", "aba",共5个。内容相同位置不同的子序列算不同的子序列。输入第一行一个整数T,表示数据组数。之后是T组数据,每组数据为一行字符串。输出对于每组数据输出一行,格式为"Case #X: Y",X代表数据编号(从1开始)原创 2015-04-18 15:38:22 · 450 阅读 · 0 评论 -
【codechef】Save Spaceman Spiff(人能否安全从起点走到终点)
https://www.codechef.com/ZCOPRAC/problems/ZCO13004 似乎交不了题目了,所以没法验证对错,但是同标程的做法是一样的。题意:有一块n*m大小的地图,一个人要从(1,1)走到(n,m),只能往右/往下走。但是路上会有很多怪物,这些怪物的位置是B(见下图),第i个怪物从ci时间开始活动,有一个周期di,它在这段时间内的运动轨迹如下图P(a=3,b=原创 2015-11-25 19:12:47 · 633 阅读 · 0 评论 -
【codechef】s=abs(这部分数-剩下的数),求所有选取方式的s之和
https://www.codechef.com/KOL15MOS/problems/KOL1502 印度的区域赛,很遗憾赛后不能提交了。。。原本一直找不到正确的AC打开方式,实在也算道脑洞题吧。下午课上突然想到如何解题了,这种灵光一现的时刻多一点该有多好。。。一组数据,从中选取一部分数,s=max(这部分数-剩下的数,剩下的数-这部分数),即abs(这部分数-剩下的数)。求所有选取方式的原创 2015-12-28 20:00:20 · 729 阅读 · 0 评论 -
【51nod】1092 回文字符串
回文串是指aba、abba、cccbccc、aaaa这种左右对称的字符串。每个字符串都可以通过向中间添加一些字符,使之变为回文字符串。例如:abbc 添加2个字符可以变为 acbbca,也可以添加3个变为 abbcbba。方案1只需要添加2个字符,是所有方案中添加字符数量最少的。两种截然不同的思路:1.先求出原字符串与逆序字符串的最长公共子序列(可不连续),ans=总长度-原创 2015-11-14 12:18:46 · 1411 阅读 · 0 评论 -
HDU 5353 Average(破解环的做法是枚举起始点の操作,灵活题)
题目链接:点击打开链接(转自:http://www.bubuko.com/infodetail-1024312.html)题目大意:有n个人围城一个环,每一个人手里都有一些糖果,第i个人有ai块。现在有三种操作:第i个人给第i+1个人一块。如果i有第i+1个人给第i个人一块。如果i+1有什么都不做。第i个人和第i+1个人之间,可以选择一种操作并执转载 2015-11-07 19:03:39 · 510 阅读 · 0 评论 -
【codechef】Strategy for the World Cup(组合打表)
Input:610 2 96 2 96 1 94 1 95 1 910 3 9Output:2411012http://www.codechef.com/COOK55/problems/WORLDCUP组合和0-l的组合累加都要先打好表,不然会超时。#include using namespace std;#define M 1000000007原创 2015-05-19 19:23:02 · 359 阅读 · 0 评论 -
【hiho四十八周】 求最后感染到的病毒总数(拓扑排序模板)
小Hi和小Ho所在学校的校园网被黑客入侵并投放了病毒。这事在校内BBS上立刻引起了大家的讨论,当然小Hi和小Ho也参与到了其中。从大家各自了解的情况中,小Hi和小Ho整理得到了以下的信息:校园网主干是由N个节点(编号1..N)组成,这些节点之间有一些单向的网路连接。若存在一条网路连接(u,v)链接了节点u和节点v,则节点u可以向节点v发送信息,但是节点v不能通过该链接向节点u发送信息。在刚原创 2015-06-04 21:33:40 · 871 阅读 · 0 评论 -
hdu 5207 求数组中任取两数的gcd最大值(灵活题)
Pick two numbers ai,aj(i≠j) from a sequence to maximize the value of their greatest common divisor. InputMultiple test cases. In the first line there is an integer T, indicating the原创 2015-05-01 17:01:41 · 955 阅读 · 0 评论 -
【codechef】Nikhil and Commands(字符串删减,分类)
Nikhil learnt two new commands pwd and cd on the first day of Operating Systems lab.pwd - command displays the current working directory and,cd - changes the location of working directory.原创 2015-05-02 22:07:33 · 517 阅读 · 0 评论 -
ZOJ 3725 Painting Storages(很好的dp题)
There is a straight highway with N storages alongside it labeled by 1,2,3,...,N. Bob asks you to paint all storages with two colors: red and blue. Each storage will be painted with exactly one color.原创 2015-05-09 11:06:25 · 445 阅读 · 0 评论 -
【codechef】Arush Challenge(灵活题)
Arush was not always poor at Mathematics but his recent performances had not been that good and he had lost his confidence. Now his elder brother was determined to bring back his confidence back in Ma原创 2015-05-02 22:01:55 · 473 阅读 · 0 评论 -
zoj 3879 Capture the Flag(长模拟)
In computer security, Capture the Flag (CTF) is a computer security competition. CTF contests are usually designed to serve as an educational exercise to give participants experience in securing a mac原创 2015-04-29 21:58:37 · 658 阅读 · 0 评论 -
zoj3872 Beauty of Array(dp)
Edward has an array A with N integers. He defines the beauty of an array as the summation of all distinct integers in the array. Now Edward wants to know the summation of the beauty of all contiguous原创 2015-04-29 10:29:20 · 506 阅读 · 0 评论