Gym 101673F Keeping On Track】的更多相关文章

原题传送门 题意:给定一颗n+1(n≤10000)个结点的树(当然有n条边辣),定义一个结点为critical,当且仅当除去这个点及与其相连的边后,所有不相连的结点对数量最多.现在保证有且仅有一个结点是critical的,要求输出对应的不相连的结点对数,以及连上一条边后,能剩余的最少结点对数(即等价于(n+1-最佳情况下能减少的不相连点对个数)). 分析:明眼人一下就能看出,第二问比第一问简单多了,只要求出critical,然后O(n)跑一遍邻边统计最大的两个分支乘起来就是"最佳情况下能减少的不…
树上每个割点计算一下各个size的组合相乘再相加为第一问答案,取最大的:再把本答案中最大的两个size相乘减掉,为第二问答案. const int maxn = 1e4 + 5; int n, size[maxn], ans, b; vector<int> adj[maxn]; void dfs(int cur, int fa) { size[cur] = 1; vector<int> v; for (auto i : adj[cur]) { if (i == fa) contin…
题目链接:https://cn.vjudge.net/problem/UVALive-8072 题意 给出n+1个点和n条边,每对点之间只能存在一条边. 现在要找出一个节点,使得去掉这个点后,所剩每对不联通点的点对数最大. 还要在去掉这个点后加上一条边,使得加上这个边后,不联通点对数最小. 例: 6 0 1 1 2 2 3 2 4 4 5 4 6 答:11 5 思路 看不懂题意,更看不懂样例:只能临场猜题意,猜样例. 现在解释一下样例的意思. 首先画出这个无向图,然后找特殊节点.我帮你找到2这个…
If you've worked with Django at some point you probably had the need for some background processing of long running tasks. Chances are you've used some sort of task queue, and Celery is currently the most popular project for this sort of thing in the…
A .Abstract Art 题意:求多个多边形的面积并. 思路:模板题. #include<bits/stdc++.h> using namespace std; typedef long long ll; const double inf=1e200; ; *atan(1.0); :(x<?-:);} struct point{ double x,y; point(,):x(a),y(b){} }; point operator +(point A,point B) { retur…
A:Abstract Art 题意:给出n个多边形,求n个多边形分别的面积和,以及面积并 思路:模板 #include <bits/stdc++.h> using namespace std; #define N 1010 #define mkp make_pair ; inline int sgn(double x) { ; ) ; ; } struct Point { double x, y; inline Point() {} inline Point(double x, double…
ECNA 2017 Abstract Art 题目描述:求\(n\)个多边形的面积并. solution 据说有模板. Craters 题目描述:给定\(n\)个圆,求凸包的周长. solution 求出两两圆的公切线的切点,做凸包,算周长时判断两个点是否在同一个圆上,以及是优弧还是劣弧. 或是将每个圆拆成\(3000\),做凸包,算周长时判断两个点是否在同一个圆上. 时间复杂度:\(O(n^2)\) DRM Messages 题目描述: solution 模拟 Game of Throwns…
Problem I. Instruction 题目连接: http://codeforces.com/gym/100531/attachments Description Ingrid is a head of a big railway station and, among other duties, is responsible for routing trains to the right platforms. The station has one entrance, and there…
Music Mess Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments Description Francis really likes his music. He especially likes that song ’Zombie Nation’. Or was that the album? Or maybe the album was ’Kernkraft 4…
Spies Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100463/attachments Description In the aftermath of Canada’s annexation of Pittsburgh tensions have been pretty high between Canada and the US. You have personally been hired…