标签:pair put inline pac names pre clu comment typedef
题意:略。
析:首先先找出来两种圆,一种是只包含怪物的,另一种是只包含雅典娜的,因为都包含或者都不包含的没什么意义,排序,从小到大按半径,然后分别进行dp,最后肯定是包含的选出最多一个,然后再进行合并。
代码如下:
#pragma comment(linker, "/STACK:1024000000,1024000000") #include <cstdio> #include <string> #include <cstdlib> #include <cmath> #include <iostream> #include <cstring> #include <set> #include <queue> #include <algorithm> #include <vector> #include <map> #include <cctype> #include <cmath> #include <stack> #include <sstream> #include <list> #include <assert.h> #include <bitset> #define debug() puts("++++"); #define gcd(a, b) __gcd(a, b) #define lson l,m,rt<<1 #define rson m+1,r,rt<<1|1 #define fi first #define se second #define pb push_back #define sqr(x) ((x)*(x)) #define ms(a,b) memset(a, b, sizeof a) #define sz size() #define pu push_up #define pd push_down #define cl clear() #define all 1,n,1 #define FOR(i,x,n) for(int i = (x); i < (n); ++i) #define freopenr freopen("in.txt", "r", stdin) #define freopenw freopen("out.txt", "w", stdout) using namespace std; typedef long long LL; typedef unsigned long long ULL; typedef pair<int, int> P; const int INF = 0x3f3f3f3f; const double inf = 1e20; const double PI = acos(-1.0); const double eps = 1e-8; const int maxn = 1000 + 10; const int maxm = 1e5 + 10; const int mod = 50007; const int dr[] = {-1, 0, 1, 0}; const int dc[] = {0, -1, 0, 1}; const char *de[] = {"0000", "0001", "0010", "0011", "0100", "0101", "0110", "0111", "1000", "1001", "1010", "1011", "1100", "1101", "1110", "1111"}; int n, m; const int mon[] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; const int monn[] = {0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; inline bool is_in(int r, int c) { return r >= 0 && r < n && c >= 0 && c < m; } struct Point{ int x, y; Point() { } Point(int xx, int yy) : x(xx), y(yy) { } friend Point operator - (const Point &lhs, const Point &rhs){ return Point(lhs.x - rhs.x, lhs.y - rhs.y); } }; int dist(Point p){ return sqr(p.x) + sqr(p.y); } struct Circle{ Point c; int r; bool operator < (const Circle &c) const{ return r < c.r; } }; Circle c[maxn]; Point athene, monster; int isintersection(const Point &p, const Circle &c){ int d = dist(p - c.c); return d - sqr(c.r); } bool not_intersection(const Circle &c1, const Circle &c2){ int d = dist(c1.c - c2.c); return d > sqr(c1.r + c2.r); } bool isinclude(const Circle &c1, const Circle &c2){ int d = dist(c1.c - c2.c); return sqr(c1.r - c2.r) > d; } vector<Circle> aths, mos; int f[maxn], g[maxn]; int main(){ monster.x = monster.y = 0; int T; cin >> T; for(int kase = 1; kase <= T; ++kase){ mos.cl; aths.cl; scanf("%d %d %d", &n, &athene.x, &athene.y); for(int i = 0; i < n; ++i){ scanf("%d %d %d", &c[i].c.x, &c[i].c.y, &c[i].r); int id1 = isintersection(athene, c[i]); int id2 = isintersection(monster, c[i]); if(id1 < 0 && id2 > 0) aths.push_back(c[i]); else if(id1 > 0 && id2 < 0) mos.push_back(c[i]); } sort(aths.begin(), aths.end()); sort(mos.begin(), mos.end()); int ans = 0; for(int i = 0; i < aths.sz; ++i){ f[i] = 1; for(int j = 0; j < i; ++j) if(isinclude(aths[i], aths[j])) f[i] = max(f[i], f[j] + 1); ans = max(ans, f[i]); } for(int i = 0; i < mos.sz; ++i){ g[i] = 1; for(int j = 0; j < i; ++j) if(isinclude(mos[i], mos[j])) g[i] = max(g[i], g[j] + 1); ans = max(ans, g[i]); } for(int i = 0; i < aths.sz; ++i) for(int j = 0; j < mos.sz; ++j) if(not_intersection(aths[i], mos[j])) ans = max(ans, f[i] + g[j]); printf("Case %d: %d\n", kase, ans); } return 0; }
标签:pair put inline pac names pre clu comment typedef
原文地址:http://www.cnblogs.com/dwtfukgv/p/7643440.html