Codeforces 1082 G - Petya and Graph】的更多相关文章

G - Petya and Graph 思路: 最大权闭合子图 对于每条边,如果它选了,那么它连的的两个点也要选 边权为正,点权为负,那么就是求最大权闭合子图 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include<bits/stdc++.h> using namespace std; #define fi first #define se second #define pi ac…
题目传送门 题意:现在有一个图,选择一条边,会把边的2个顶点也选起来,最后会的到一个边的集合 和一个点的集合 , 求边的集合 - 点的集合最大是多少. 题解:裸的最大权闭合子图. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","r",stdin); freopen("_out.txt","w",std…
题:https://codeforces.com/contest/1082/problem/G 题意:给定有边权和点权的图,问你选一些边,然sum边-sum点最大(点权被多次用为公共点只会减一次) 分析:求最大闭合子图 选了点就要减去该点点权,选了边就加边权,然而俩点确定一边,我们可以理解为要做成一件事需要消耗(点权),事成后会有一定的利益(边权). 这就和网络流24题中的第二题很像了,也是经典的求利润最大化的问题,可以网络流解决,具体如下: 总的操作:先算总的利益,再减去最小割. 对于利益,我…
Petya has a simple graph (that is, a graph without loops or multiple edges) consisting of n n vertices and m m edges. The weight of the i i -th vertex is a i  ai . The weight of the i i -th edge is w i  wi . A subgraph of a graph is some set of the g…
题目传送门 题意:现在有n个点,每个点的度数最大为di,现在要求你构成一棵树,求直径最长. 题解:把所有度数为2的点先扣出来,这些就是这颗树的主干,也就是最长的距离. 然后我们把度数为2的点连起来,之后就处理1的点,先在主干的最左边和最右边加上新的点,这样可以使得直径边长. 然后其他的点随便放就好了. 代码: #include<bits/stdc++.h> using namespace std; #define Fopen freopen("_in.txt","…
原题地址:https://codeforces.com/contest/1082/problem/G G. Petya and Graph time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya has a simple graph (that is, a graph without loops or multiple e…
Petya and Graph http://codeforces.com/contest/1082/problem/G time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Petya has a simple graph (that is, a graph without loops or multiple edges) con…
[codeforces 549]G. Happy Line 试题描述 Do you like summer? Residents of Berland do. They especially love eating ice cream in the hot summer. So this summer day a large queue of n Berland residents lined up in front of the ice cream stall. We know that ea…
CodeForces 794 G.Replace All 解题思路 首先如果字符串 \(A, B\) 没有匹配,那么二元组 \((S, T)\) 合法的一个必要条件是存在正整数对 \((x,y)\),使得 \(xS=yT\),其中 \(xS\) 是将字符串 \(S\) 复制 \(x\) 遍后得到的字符串,\(yT\) 是将字符串 \(T\) 复制 \(T\) 遍后得到的字符串.由于 \(A,B\) 直接匹配的情况比较容易讨论,下面没有特殊说明,都是 \(A,B\) 没有直接匹配的情况. 这个条件…
title: NEERC 2016-2017 Probelm G. Game on Graph data: 2018-3-3 22:25:40 tags: 博弈论 with draw 拓扑排序 categories: 信息学竞赛 题目 description: 有一个有向图, 两人依次移动一个棋子, 谁不能移动谁输, 对于玩家二它如果不能赢宁愿选择输, 问先手为玩家一或二棋子初始在任意位置时先手输或赢或者是平局? --- NEERC 2016-2017 Probelm G. Game on Gr…