# tjut 3511

#include <stdio.h>
#include <string.h>
#include <math.h>
#include <set>
#include <algorithm>

using namespace std;

const int UP = 0;
const int DOWN = 1;
const int IN = 0;
const int OUT = 1;
const int N = 50005;

int Time;

struct circle {
int x, y, r;
int w;
scanf("%d %d %d", &x, &y, &r);
w = 0;
}
int getX(int flag) {
if( flag == IN )     return x - r;
else                return x + r;
}
double getY(int flag) {
double ret = sqrt((double)r*r-(double)(Time-x)*(Time-x));
if( flag == UP )     return (double)y + ret;
else                return (double)y - ret;
}

} cir[N];

struct event {
int x, y, id;
int flag;
void get(int _x, int _y, int _id, int _flag) {
x = _x;
y = _y;
id = _id;
flag = _flag;
}
bool operator<(const event ev) const {
return x < ev.x || x == ev.x && y > ev.y;
}
} eve[N*2];

struct node {
int id;
int flag;
node(){}
node(int _id, int _flag) {
id = _id;
flag = _flag;
}
bool operator<(const node a) const {
double y1 = cir[id].getY(flag);
double y2 = cir[a.id].getY(a.flag);
return y1 > y2 || y1 == y2 && flag < a.flag;
}
};

int n, eveN;

set<node> line;
set<node>::iterator it, f, e, p;

inline int max(int a, int b) { return a > b ? a : b;}

void moveline() {
line.clear();
for(int i = 0; i < eveN; i ++) {
Time = eve[i].x;
if( eve[i].flag == OUT ) {
line.erase(node(eve[i].id, UP));
line.erase(node(eve[i].id, DOWN));
} else {
it = line.insert(node(eve[i].id, UP)).first;
e = f = it;
e ++;
int id = it->id;
if( it == line.begin() || e == line.end() ) {
cir[id].w = 1;
} else {
f --;
if( f->id == e->id ) {
cir[id].w = cir[f->id].w + 1;
} else {
cir[id].w = max( cir[f->id].w, cir[e->id].w);
}
}
line.insert(node(eve[i].id, DOWN));
}
}
}

int main() {
while( scanf("%d", &n) != EOF ) {
eveN = 0;
for(int i = 0; i < n; i ++) {
eve[eveN++].get(cir[i].getX(IN), cir[i].y, i, IN);
eve[eveN++].get(cir[i].getX(OUT), cir[i].y, i, OUT);

}
sort(eve, eve + eveN);
moveline();
int ans = 0;
for(int i = 0; i < n; i ++) {
ans = max(ans, cir[i].w);
}
printf("%d\n", ans);
}
}


• 本文已收录于以下专栏：

举报原因： 您举报文章：tjut 3511 色情 政治 抄袭 广告 招聘 骂人 其他 (最多只允许输入30个字)