大意: 给定n个不相交的圆, 求将n个圆划分成两部分, 使得阴影部分面积最大. 贪心, 考虑每个连通块, 最外层大圆分成一部分, 剩余分成一部分一定最优. #include <iostream> #include <iostream> #include <algorithm> #include <cstdio> #include <math.h> #include <set> #include <map> #include…
Codeforces Round #418 (Div. 2) D. An overnight dance in discotheque 题意: 给\(n(n <= 1000)\)个圆,圆与圆之间不存在相交关系,只存在包含与不包含关系,现在问你把这一堆圆分成两组,求每组圆的异或并和的最大值. 思路:最简单的做法是贪心的做法,算出每个圆被包含的次数,为偶数则贡献为正,奇数为贡献为负. 现在主要学习一下树形dp的做法 由于圆不存在相交的情况,所以可以把所有的圆建成树,即把每棵树上的点分成两组,分别建成…
An overnight dance in discotheque time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spaciousne…
The crowdedness of the discotheque would never stop our friends from having fun, but a bit more spaciousness won't hurt, will it? The discotheque can be seen as an infinite xy-plane, in which there are a total of n dancers. Once someone starts moving…
题目链接 正解:贪心. 首先我们可以计算出每个圆被多少个圆覆盖. 很显然,最外面的圆是肯定要加上的. 然后第二层的圆也是要加上的.那么第三层就不可能被加上了.同理,第四层的圆又一定会被加上. 然后我们可以发现一个贪心策略,没被覆盖和被覆盖奇数次的圆加上,被覆盖偶数次的圆减去. 可以发现这样的贪心策略是最优的. #include <bits/stdc++.h> #define il inline #define RG register #define ll long long #define N…
题目链接:http://codeforces.com/contest/814/problem/D 题意:给出奇数个舞者,每个舞者都有中心坐标和行动半径,而且这些点组成的园要么相互包含要么没有交集求,讲这些点分成两部分最大面积是多少. 面积计算方法详见题目,很好理解有图示. 题解:这题挺简单的就考虑一下包含与不包含的就行了.具体看一下代码挺好理解的,主要是题目给出的这些点组成的园要么相互包含要么没有交集求导致 这题变得很简单 #include <iostream> #include <cm…
一道树形dp裸体,自惭形秽没有想到 首先由于两两圆不能相交(可以相切)就决定了一个圆和外面一个圆的包含关系 又可以发现这样的树中,奇数深度的圆+S,偶数深度的圆-S 就可以用树形dp 我又写挫了= = #include<cmath> #include<map> #include<iostream> #include<cstring> #include<cstdio> #include<set> #include<vector&g…
大致题意: 给出N个红点和M个蓝点,问可以有多少个红点构成的三角形,其内部不含有蓝点 假设我们现在枚举了一条线段(p[i],p[j]),我们可以记录线段下方满足(min(p[i].x,p[j].x)<x<=max(p[i].x,p[j].x) 的数量  时间复杂度为O(N*N*M) 那么我们就可以枚举三角形O(1)判断三角形内有无红点. #include<cstdio> #include<iostream> #include<cstring> #includ…
题意略. 思路: 由于不重合这个性质,我们可以将每一个堆叠的圆圈单独拿出来考虑,而不用去考虑其他并列在同一层的存在, 在贪心解法下,发现,被嵌套了偶数层的圆圈永远是要被减去的,而奇数层的圆圈是要加上的. 详见代码: #include<bits/stdc++.h> #define maxn 1005 #define eps 1e-8 #define pi acos(-1.0) using namespace std; struct Circle{ double x,y,r; Circle(,,)…
题意:给n个点,问是否能两条平行线覆盖所有的点 思路:因为要求全部覆盖,所以我们第一个点肯定是会入其中一条直线,其实只用判前三个点的所有情况即可 #include<stdio.h> #include<set> #include<algorithm> using namespace std; ],n; set<double>s; bool judge(double k) { s.clear(); ; i<=n; ++i) s.insert(a[i]*1.…