HDU 4781 Assignment For Princess 构造】的更多相关文章

题意: 构造一个\(N(10 \leq N \leq 80)\)个顶点\(M(N+3 \leq M \leq \frac{N^2} {7})\)条边的有向图,要满足如下条件: 每条边有一个\([1,M]\)之间的权值,而且每条边的权值都是独一无二的 该有向图是强联通的,即任意两点都互相可达 图没有自环,而且任意两点之间最多有一条边 可以从任意一点出发,经过任意条边,一条边可以走多次,再回到出发点 符合上述要求的路径权值之和为3的倍数 分析: 首先我们构造一个长度为\(N\)的环,而且环的权值之和…
http://acm.hdu.edu.cn/showproblem.php?pid=4781 由于题目太长,这里就不直接贴了,直接说大意吧. 题目大意:有一个n个点,m条边的有向图,每条边的权值分别为1,2,3........m,让你构造满足下列条件的有向图. 1:每两个点之间最多只有一条有向边,且不存在自环. 2:从任意点出发都可以达到其他任意一个点,包括自己. 3:任意一个有向环的权值和都是3的倍数. 思路:首先我们可以将点1到n连成一条链,边的权值分别是1到n-1,然后点n到点1连一条边,…
题目链接:hdu4781 Assignment For Princess 题意:n个点m条边,每条有向边的权值分别是1,2,3…m,一个点能到达任意一个点,没有重边和自环,没有任何两条边的权值相同,任意一个有向环的权值和必须是3的倍数,现在需要把这个图输出来. 题解:注意到题目给出的范围m >= n+3,所以一定是可以构造出一个1~n的回路使得权值和为3的倍数的,可以让前n-1条边权值为1~n-1,第n条边(n->1)可以为n, n+1, n+2从而满足题意,后面再连任意两条不相邻的边时,边权…
HDU 2853 Assignment 题目链接 题意:如今有N个部队和M个任务(M>=N),每一个部队完毕每一个任务有一点的效率,效率越高越好.可是部队已经安排了一定的计划,这时须要我们尽量用最小的变动,使得全部部队效率之和最大.求最小变动的数目和变动后和变动前效率之差. 思路:对于怎样保证改变最小,没思路,看了别人题解,恍然大悟,表示想法很机智 试想,假设能让原来那些匹配边,比其它匹配出来总和同样的权值还大,对结果又不影响,那就简单了,这个看似不能做到,事实上是能够做到的 数字最多选出50个…
HDU 5289 - Assignment http://acm.hdu.edu.cn/showproblem.php?pid=5289 Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task t…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2853 Last year a terrible earthquake attacked Sichuan province. About 300,000 PLA soldiers attended the rescue, also ALPCs. Our mission is to solve difficulty problems to optimization the assignment of t…
原题直通车:HDU 4308 Saving Princess claire_ 分析: 两次BFS分别找出‘Y’.‘C’到达最近的‘P’的最小消耗.再算出‘Y’到‘C’的最小消耗,比较出最小值 代码: #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<string> using namespace std; const int inf=0xF…
http://acm.hdu.edu.cn/showproblem.php?pid=6313 题意 让你构造一个矩阵使得里面不存在四个顶点都为1的矩形,并且矩阵里面1的个数要>=85000 分析 来自https://blog.csdn.net/qq_37025443/article/details/81221008 先从25*25的构造看起 10000 01000 00100 00010 0000110000 00100 00001 01000 0001010000 00010 01000 00…
Prince and Princess 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=4685 Description There are n princes and m princesses. Princess can marry any prince. But prince can only marry the princess they DO love. For all princes,give all the princesses tha…
Assignment 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5289 Description Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special…
http://acm.hdu.edu.cn/showproblem.php?pid=1029 Problem Description "OK, you are not too bad, em... But you can never pass the next test." feng5166 says. "I will tell you an odd number N, and then N integers. There will be a special integer…
Assignment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 3813    Accepted Submission(s): 1771 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered…
几天前模拟区域赛的一道题,今天发现在草稿箱里直接补个博客. 感觉这还是一道很有意思的构造题. 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5573 题意: 给你一个二叉树,根节点为1,子节点为父节点的2倍和2倍+1,从根节点开始依次向下走k层,问如何走使得将路径上的数进行加减最终结果得到n. 分析: 首先明确由1.2.4...2k可以构造出所有小于2k+1的数,那么实际上只要走2的幂次即最左边的结点即可. 那么实际上这个过程就类似整数的二进制表…
题目链接:pid=5289">http://acm.hdu.edu.cn/showproblem.php?pid=5289 题面: Assignment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 672    Accepted Submission(s): 335 Problem Description Tom owns a…
HDU 6879 - Mine Sweeper 题意 定义<扫雷>游戏的地图中每个空白格子的值为其周围八个格子内地雷的数量(即游戏内临近地雷数量的提示) 则一张地图的值\(S\)为所有空白格子的值总和 现给定\(S\),要求构造出一张长度与宽度均不超过\(25\)的地图,使其值等于\(S\) 限制 \(1\leq T\leq 1001\) \(0\leq S\leq 1000\) 思路 这题过的人数应该是最多的,所以肯定是存在比我的想法更优更方便的解的 但是题解写的不是很清楚,所以还是写下了这…
 Ignatius and the Princess III Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u   Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says.  "Th…
http://acm.hdu.edu.cn/showproblem.php?pid=2256 题意:给定 n    求解   ? 思路: , 令  , 那么 , 得: 得转移矩阵: 但是上面求出来的并不是结果,并不是整数.需要加上, 由于 所以结果为 #pragma comment(linker, "/STACK:1024000000,1024000000") #include<bits/stdc++.h> using namespace std; #define rep0…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4685 题意:给出n个王子和m个公主.每个王子有一些自己喜欢的公主可以匹配.设最大匹配为M.那么对于每个王子,可以选择哪些自己喜欢的公主使得选择之后最大匹配仍为M? 思路:(1)首先,想到的一个方法是先求一次最大匹配.然后枚举每个王子喜欢的公主作为该王子的匹配,判断能否为之前匹配该公主的王子重新找到一个匹配.这样的复杂付太大. (2)改进:做法是先求一次最大匹配设为cnt,那么左边有n-cnt个王子还…
Assignment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 627    Accepted Submission(s): 318 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered fr…
[题目链接] http://acm.hdu.edu.cn/showproblem.php?pid=5741 [题目大意] 一个01相间的串,以0开头,给出的序列每个数字表示连续的0的个数或者1的个数,现在有m个询问,求0的个数为a且1的个数为b的串是否存在. [题解] 我们发现形如11001这样子以1为开头结尾的串是包含1001这样子的串的,同理以0为开头结尾的串也是包含了一些开头结尾数字相同的子串. 可以发现,当0的个数固定,1的个数是数轴上的一个区间,而且在0的个数相差1时,必定可以取到相同…
http://acm.hdu.edu.cn/showproblem.php?pid=5573 题意:给出一个满二叉树,根节点权值为1,左儿子为2*val,右儿子为2*val+1.现在有只青蛙从根节点出发,一步步往下走,在每个节点它都要选择加上该点的权值还是减去该点的权值,如果正好经过k个节点时总的权值和为n,那么这只青蛙就成功了,需要输出方案. 思路: 这道题目要注意到n<=(1<<k). 所以如果每次都走这棵二叉树的左节点的话,权值就是1,2,4,8,10,那么它就可以组成小于(1&l…
http://acm.hdu.edu.cn/showproblem.php?pid=6150 #include<iostream> #include<algorithm> #include<cstring> #include<cstdio> #include<vector> #include<stack> #include<queue> #include<cmath> #include<map> #…
题目链接: Assignment  题意: 给出一个数列,问其中存在多少连续子序列,使得子序列的最大值-最小值<k. 题解: RMQ先处理出每个区间的最大值和最小值(复杂度为:n×logn),相当于求出了每个区间的最大值-最小值.那么现在我们枚举左端点,二分右端点就可以在n×logn×logn的时间内过. #include<bits/stdc++.h> using namespace std; ; int vec[MAX_N]; ]; ]; ; int N,M,T; void ST(in…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5289 题意:给你n个数和k,求有多少的区间使得区间内部任意两个数的差值小于k,输出符合要求的区间个数 思路:求出区间的最大最小值,只要他们的差值小于k,那么这个区间就符合要求,但是由于n较大,用暴力一定超时,所以就要用别的方法了:而RMQ是可以求区间的最值的,而且预处理的复杂度只有O(nlogn),而查询只是O(1)处理,这样相对来说节约了时间,再根据右端点来二分枚举左端点(其实不用二分好像更快,估…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5289 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special tas…
Prince and Princess Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)Total Submission(s): 150    Accepted Submission(s): 46 Problem Description There are n princes and m princesses. Princess can marry any prince. But…
Assignment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 902    Accepted Submission(s): 441 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered fro…
Ignatius and the Princess II Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other) Total Submission(s) : 2   Accepted Submission(s) : 1 Problem Description Now our hero finds the door to the BEelzebub feng5166. He opens the…
Ignatius and the Princess II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 6191    Accepted Submission(s): 3664 Problem Description Now our hero finds the door to the BEelzebub feng5166. He o…
Assignment Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 617    Accepted Submission(s): 314 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered fr…