Conscription(POJ 3723)】的更多相关文章

原题如下: Conscription Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 16584   Accepted: 5764 Description Windy has a country, and he wants to build an army to protect his country. He has picked up N girls and M boys and wants to collect the…
  男女搭配,干活不累 题目大意:需要招募女兵和男兵,每一个人都的需要花费1W元的招募费用,但是如果有一些人之间有亲密的关系,那么就会减少一定的价钱,如果给出1~9999的人之间的亲密关系,现在要你求招募所有人的时候,最少的价格? 看似这一题要用到二分图,其实根本用不上,我们仔细想一下我们如果把所有的男和女都看成人的话,那么其实我们就是要求这些关系的最大值的负值(也就是最小生成树) 这样一看,这题其实很裸,要注意区分男和女就行(别搞错男女了,不然就RE了),男的点的位置就看成是女的总数+男的坐标…
Windy has a country, and he wants to build an army to protect his country. He has picked up N girls and M boys and wants to collect them to be his soldiers. To collect a soldier without any privilege, he must pay 10000 RMB. There are some relationshi…
http://poj.org/problem?id=3723 windy需要挑选N各女孩,和M各男孩作为士兵,但是雇佣每个人都需要支付10000元的费用,如果男孩x和女孩y存在亲密度为d的关系,只要他们其中有一个已经被选中,那么在选另一个人需要的费用为100000-d,给定R个关系,输出一个最低费用,每个关系只能使用一次. 把人看作顶点,关系看作边,就可以转化为无向图中的最大权森林问题,最大权森林问题可以通过把所有边权取反之后用最小生成树的算法求解. #include <cstdio> #in…
[题目链接] http://poj.org/problem?id=3723 [题目大意] 招募名单上有n个男生和m个女生,招募价格均为10000, 但是某些男女之间存在好感,则招募的时候, 可以降低与已招募人员中最大好感度的值, 求一定招募顺序使得招募总价格最小,输出最小价格 [题解] 对于存在好感度的男女之间连边,那么答案就是总价格减去最大权森林 [代码] #include <cstdio> #include <algorithm> using namespace std; in…
http://poj.org/problem?id=3723 题目大意: 需要征募女兵N人,男兵M人,没征募一个人需要花费10000美元,但是如果已经征募的人中有一些关系亲密的人,那么可以少花一些钱,给出若干男女之间的1~9999之间的亲密度关系,征募某个人的费用是10000-(已经征募的人中和自己的亲密度的最大值),要求通过适当的征募顺序使得征募所有人的花费最小. 思路: 好几天没刷题,来水一发 征募了某个人a时,如果使用了a和b之间的关系,那么就连一条从a到b的边.那么根据贪心算法,每次选择…
题目链接: 题目 Conscription Time Limit: 1000MS Memory Limit: 65536K 问题描述 Windy has a country, and he wants to build an army to protect his country. He has picked up N girls and M boys and wants to collect them to be his soldiers. To collect a soldier witho…
Conscription Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6325   Accepted: 2184 Description Windy has a country, and he wants to build an army to protect his country. He has picked up N girls and M boys and wants to collect them to be…
Conscription Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 14661   Accepted: 5102 Description Windy has a country, and he wants to build an army to protect his country. He has picked up N girls and M boys and wants to collect them to b…
Conscription Descriptions 需要征募女兵N人,男兵M人. 每招募一个人需要花费10000美元. 如果已经招募的人中有一些关系亲密的人,那么可以少花一些钱. 给出若干男女之前的1 ~ 9999 之间的亲密度关系, 招募某个人的费用是 10000 - (已经招募了的人中和自己的亲密度的最大值). 要求通过适当的招募顺序使得招募所有人所花费的费用最小. Input 输入N, M, R;接下来输入R行 (x, y, d) 表示第 x 号男兵和第 y 号女兵之间的亲密度是 d Ou…
题意: 征用一些男生和女生,每个应都要给10000元,但是如果某个男生和女生之间有关系,则给的钱数为10000减去相应的亲密度,征集一个士兵时一次关系只能使用一次. 分析: kruskal求最小生成树,注意男生和女生用偏移量处理. 代码: #include<iostream> #include<algorithm> #include<cstdio> using namespace std; struct edge{int u, v, w;}; const int max…
POJ 3237 Tree 题目链接 就多一个取负操作,所以线段树结点就把最大和最小值存下来,每次取负的时候,最大和最小值取负后.交换就可以 代码: #include <cstdio> #include <cstring> #include <vector> #include <algorithm> using namespace std; const int N = 10005; const int INF = 0x3f3f3f3f; int dep[N]…
Conscription Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 15923   Accepted: 5510 Description Windy has a country, and he wants to build an army to protect his country. He has picked up N girls and M boys and wants to collect them to b…
最大生成树 #include<iostream> #include<cstdio> #include<cstring> #include<set> #include<algorithm> #include<stack> #include<map> #include<queue> #include<list> #include<vector> using namespace std; co…
A - Lake Counting POJ - 2386 最最最最最基础的dfs 挂这道题为了提高AC率(糖水不等式 B - Paint it really, really dark gray CodeForces - 717E dfs 待会写题解 C - New Year Transportation CodeForces - 500A 简单的模拟 D - Binary Tree Traversals HDU - 1710 给树的先序中序输出后序 贴下代码 #include <algorith…
POJ 1852 Ants POJ 2386 Lake Counting POJ 1979 Red and Black AOJ 0118 Property Distribution AOJ 0333 Ball POJ 3009 Curling 2.0 AOJ 0558 Cheese POJ 3669 Meteor Shower AOJ 0121 Seven Puzzle POJ 2718 Smallest Difference POJ 3187 Backward Digit Sums POJ 3…
[今天我出的三道题目全部是图论哦,请大家轻虐] 1.魔术球问题弱化版(ball.c/.cpp/.pas) 题目描述 假设有 n 根柱子,现要按下述规则在这 n 根柱子中依次放入编号为 1,2,3,…的球. (1)每次只能在某根柱子的最上面放球. (2)在同一根柱子中,任何 2 个相邻球的编号之和为完全平方数. 试设计一个算法,计算出在 n 根柱子上最多能放多少个球.例如,在 4 根柱子上最多可放 11 个球. 对于给定的 n,计算在 n 根柱子上最多能放多少个球. 输入描述 第 1 行有 1 个…
#define _CRT_SECURE_NO_WARNINGS /* 5 5 8 4 3 6831 1 3 4583 0 0 6592 0 1 3063 3 3 4975 1 3 2049 4 2 2104 2 2 781 */ #include <iostream> #include <vector> #include <algorithm> #include <cstdio> using namespace std; + ; ; ; int par[ma…
http://poj.org/problem?id=3723 这题虽然简单,但是还是错了很多次. 因为这题构建的图可能是不连通的.也就是说可能有很多棵树. 所以我以前写的并查集用在这上面会出问题的. while(x != f[x]) x = f[x]; return f[x]; //我这样子每次用完之后并没有更新f[x]的值. //虽然在连通图中没问题,但是在不连通的图里用就会有问题啦. 血的教训.... 改正: if(x !=f[x]) f[x] = find(f[x]); return f[…
Conscription Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8071   Accepted: 2810 Description Windy has a country, and he wants to build an army to protect his country. He has picked up N girls and M boys and wants to collect them to be…
Halloween treats Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 7644   Accepted: 2798   Special Judge Description Every year there is the same problem at Halloween: Each neighbour is only willing to give a certain total number of sweets…
Find a multiple Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 7192   Accepted: 3138   Special Judge Description The input contains N natural (i.e. positive integer) numbers ( N <= 10000 ). Each of that numbers is not greater than 15000…
The Pilots Brothers' refrigerator Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 22286   Accepted: 8603   Special Judge Description The game “The Pilots Brothers: following the stripy elephant” has a quest where a player needs to open a…
Flip Game Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 37427   Accepted: 16288 Description Flip game is played on a rectangular 4x4 field with two-sided pieces placed on each of its 16 squares. One side of each piece is white and the…
Corn Fields Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 9806   Accepted: 5185 Description Farmer John has purchased a lush new rectangular pasture composed of M by N (1 ≤ M ≤ 12; 1 ≤ N ≤ 12) square parcels. He wants to grow some yumm…
Sum of Consecutive Prime Numbers Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 20050   Accepted: 10989 Description Some positive integers can be represented by a sum of one or more consecutive prime numbers. How many such representatio…
Tree Recovery Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 11939   Accepted: 7493 Description Little Valentine liked playing with binary trees very much. Her favorite game was constructing randomly looking binary trees with capital le…
Seek the Name, Seek the Fame Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 17898   Accepted: 9197 Description The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the little cat to give names t…
题目: poj 2352 Stars 数星星 题意:已知n个星星的坐标.每个星星都有一个等级,数值等于坐标系内纵坐标和横坐标皆不大于它的星星的个数.星星的坐标按照纵坐标从小到大的顺序给出,纵坐标相同时则按照横坐标从小到大输出. (0 <= x, y <= 32000) 要求输出等级0到n-1之间各等级的星星个数. 分析: 这道题不难想到n平方的算法,即从纵坐标最小的开始搜,每次找它前面横坐标的值比它小的点的个数,两个for循环搞定,但是会超时. 所以需要用一些数据结构去优化,主要是优化找 横坐…
poj   1251  Jungle Roads  (最小生成树) Link: http://poj.org/problem?id=1251 Jungle Roads Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 23507   Accepted: 11012 Description The Head Elder of the tropical island of Lagrishan has a problem. A b…