UVA1613-K-Graph Oddity(贪心)】的更多相关文章

"Oh, There is a bipartite graph.""Make it Fantastic." X wants to check whether a bipartite graph is a fantastic graph. He has two fantastic numbers, and he wants to let all the degrees to between the two boundaries. You can pick up sev…
题目链接: 题目 Graph Construction Time limit: 3.000 seconds 问题描述 Graph is a collection of edges E and vertices V. Graph has a wide variety of applications in computer. There are different ways to represent graph in computer. It can be represented by adjace…
https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. 贪心做法: 考虑两个集合A和B,A为L<=d[i]<=R,B为d[i]>R 枚举每个边 1.如果u和v都在B集合,直接删掉2.如果u和v都在A集合,无所谓3.如果u在B,v在A,并且v可删边即d[v]>L4.如果u在A,v在B,并且u可删边即d[u]>L 最后枚举N+M个点判断是…
Problem Description Alice and Bob are playing a game on an undirected graph with n (n is even) nodes and m edges. Every node i has its own weight Wv, and every edge e has its own weight We. They take turns to do the following operations. During each…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4647 注意这题两人的决策是想要使得自己的分数与对方的差值最大.. 注意到数据范围,显然是贪心之类的,如果没有变那么很简单,如果有边,那么我们进行拆边,把边的权值的一半加到所连的点上.然后排个序贪心.. //STATUS:C++_AC_218MS_1020KB #include <functional> #include <algorithm> #include <iostream…
K.Bro Sorting Time Limit: 2000/2000 MS (Java/Others) Memory Limit: 512000/512000 K (Java/Others) Total Submission(s): 571 Accepted Submission(s): 300 Problem Description Matt's friend K.Bro is an ACMer. Yesterday, K.Bro learnt an algorithm: Bubble so…
题目链接:http://codeforces.com/gym/100283/problem/K 题解: 要使其相邻两项的差值之和最小,那么越靠中间,其数值越小. 那么剩下的问题就是如何放数字了.一开始的想法是从中间开始放,然后:左右左右--, 后来发现当为偶数个时,这种放法的字典序并非最小,应该右左右左地放.所以从中间向两边扩散的放法需要分奇偶讨论(不太好写).那有没有其他放法不用分类讨论,且一步过的?有的,就是从两边开始,往中间靠近,即右左右左一直放到中间没有剩余位置.这种放法保证了字典序大的…
题目链接 思路题.看的题解. #include <cstdio> #include <string> #include <cstring> #include <algorithm> using namespace std; #define LL __int64 LL p[]; int main() { int i,n,m,sv,ev,w; while(scanf("%d%d",&n,&m)!=EOF) { memset(p…
原题链接:K-Link-Cut Tree_第46屆ICPC 東亞洲區域賽(澳門)(正式賽) (nowcoder.com) 题意: 要求一个边权值总和最小的环,并从小到大输出边权值(2的次幂):若不存在环,输出-1. 思路: 考虑按权值从小到大加边,当出现环时(利用并查集判环),这个环必定是总权值最小的环. 找到环后,不再加边,并从环上某一点做DFS,找到从该点出发并再次回到该点的环. 代码: #include <bits/stdc++.h> #define PII pair<int,in…
题目: 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): 3175    Accepted Submission(s): 1457 Problem Description Tom owns a company and he i…