#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <iostream>
using namespace std;
#define maxn 81111
#define pb push_back
#define mp make_pair
double x[maxn], y[maxn], r[maxn];
int n;
bool in (int i, int j) { //判断圆i在不在圆j里面
double xx = x[i]-x[j], yy = y[i]-y[j];
return sqrt (xx*xx + yy*yy) + r[i] < r[j];
}
int main () {
//freopen ("in", "r", stdin);
while (scanf ("%d", &n) == 1) {
for (int i = 1; i <= n; i++) {
scanf ("%lf%lf%lf", &r[i], &x[i], &y[i]);
}
vector <pair<double, int> > a;
for (int i = 1; i <= n; i++) {
a.pb (mp (x[i]-r[i], i));
a.pb (mp (x[i]+r[i], i+n));
}
sort (a.begin (), a.end ());
set <pair<double, int> > gg; gg.clear ();
vector <int> ans; ans.clear ();
for (int i = 0; i < a.size (); i++) {
int id = a[i].second;
if (id <= n) { //左边界
set <pair<double, int> >:: iterator it = gg.lower_bound (mp (y[id], id));
if (it != gg.end () && in (id, it->second))
continue;
if (it != gg.begin () && in (id, (--it)->second))
continue;
ans.pb (id);
gg.insert (mp (y[id], id));
}
else {
id -= n;
gg.erase (mp (y[id], id));
}
}
sort (ans.begin (), ans.end ());
printf ("%d\n", ans.size ());
for (int i = 0; i < ans.size (); i++) {
printf ("%d%c", ans[i], (i+1 == ans.size () ? '\n' : ' '));
}
}
return 0;
}
POJ 2932 (扫描线)
最新推荐文章于 2020-06-12 22:52:36 发布