Problem:
Problem C:
Mobile Phone Coverage
A mobile phone company ACMICPC (Advanced Cellular, Mobile, and Internet-Connected Phone Corporation) is planning to set up a collection of antennas for mobile phones in a city called Maxnorm. The company ACMICPC has several collections for locations of antennas as their candidate plans, and now they want to know which collection is the best choice.
for this purpose, they want to develop a computer program to find the coverage of a collection of antenna locations. Each antenna
A
i
has power
r
i
, corresponding to "radius". Usually, the coverage region of the antenna may be modeled as a disk centered at the location of the antenna (
x
i
, y
i
) with radius
r
i
. However, in this city Maxnorm such a coverage region becomes the square [
x
i
−
r
i
,
x
i
+
r
i
] × [
y
i
−
r
i
,
y
i
+
r
i
]. In other words, the distance between two points (
x
p
,
y
p
) and (
x
q
,
y
q
) is measured by the max norm max{ |
x
p
−
x
q
|, |
y
p
−
y
q
|}, or, the
L
∞
norm, in this city Maxnorm instead of the ordinary Euclidean norm √ {(
x
p
−
x
q
)
2
+ (
y
p
−
y
q
)
2
}.
As an example, consider the following collection of 3 antennas
4.0 4.0 3.0
5.0 6.0 3.0
5.5 4.5 1.0
depicted in the following figure
where the
i
-th row represents
x
i
, y
i
r
i
such that (
x
i
, y
i
) is the position of the
i
-th antenna and
r
i
is its power. The area of regions of points covered by at least one antenna is 52.00 in this case.
Write a program that finds the area of coverage by a given collection of antenna locations.
Input
The input contains multiple data sets, each representing a collection of antenna locations. A data set is given in the following format.
n
x
1
y
1
r
1
x
2
y
2
r
2
. . .
x
n
y
n
r
n
The first integer
n
is the number of antennas, such that 2 ≤
n
≤ 100. The coordinate of the
i
-th antenna is given by (
x
i
, y
i
), and its power is
r
i
.
x
i
, y
i
and
r
i
are fractional numbers between 0 and 200 inclusive.
The end of the input is indicated by a data set with 0 as the value of
n
.
Output
For each data set, your program should output its sequence number (1 for the first data set, 2 for the second, etc.) and the area of the coverage region. The area should be printed with two digits to the right of the decimal point, after rounding it to two decimal places.
The sequence number and the area should be printed on the same line with no spaces at the beginning and end of the line. The two numbers should be separated by a space.
Sample Input
3
4.0 4.0 3.0
5.0 6.0 3.0
5.5 4.5 1.0
2
3.0 3.0 3.0
1.5 1.5 1.0
0
Output for the Sample Input
1 52.00
2 36.00

Submitted solutions:

code_snippet: #include <bits/stdc++.h>

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

struct node {
    ll y, l, r;
    bool isadd;

    bool operator<(const node& a) {
        return y < a.y;
    }
};

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll tc = 1;
    while(1) {
        ll n;
        cin >> n;
        if(!n) break;
        vector<node> v;
        REP(i, n) {
            double x, y, r;
            cin >> x >> y >> r;
            ll xx = x*100, yy = y*100, rr = r*100;
            v.push_back({yy-rr+20000, xx-rr+20000, xx+rr+20000, true});
            v.push_back({yy+rr+20000, xx-rr+20000, xx+rr+20000, false});
        }
        sort(ALL(v));

        vector<int> now(40001);
        ll prev = 0, width = 0, ans = 0;
        REP(i, v.size()) {
            // (y座標のdiff) * width
            ans += (v[i].y - prev) * width;
            // cout << "y:" << v[i].y << " prev:" << prev << " width:" << width << " ans:" << ans << endl;
            prev = v[i].y;
            // widthの計算
            // cout << "l:" << v[i].l << " r:" << v[i].r << " isadd:" << v[i].isadd << endl;
            if(v[i].isadd) FOR(x, v[i].l, v[i].r) now[x]++;
            else FOR(x, v[i].l, v[i].r) now[x]--;
            // cout << now << endl;
            width = 0;
            REP(x, 40001) width += (now[x]>0);
        }

        cout << tc << " " << fixed << setprecision(2) << ans/10000.0 << endl;
        tc++;
    }

    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3424
final_rank: 11

code_snippet: #include <bits/stdc++.h>
#define rep( i, begin, end) for( int i = begin; i < end; i++ )
using namespace std;
 
struct coverage {
    double x1, x2, y1, y2;
    coverage( double x1, double x2, double y1, double y2 ) : x1( x1 ), x2( x2 ), y1( y1 ), y2( y2 ) { }
};

bool confirm( const coverage &region1, const coverage &region2 )
{
    return( region1.x1 < region2.x2 && region2.x1 < region1.x2 && region1.y1 < region2.y2 && region2.y1 < region1.y2 );
}
 
int main() {
    int n, order = 0;
    double x, y, r, area;
    while( cin >> n ) {
        if( n == 0 )
            break;
        vector<coverage> square;
        vector<double> sx, sy;
        rep ( i, 0, n ) {
            cin >> x >> y >> r;
            square.push_back( coverage( x - r, x + r, y - r, y + r) );
            sx.push_back( x - r );
            sx.push_back( x + r );
            sy.push_back( y - r );
            sy.push_back( y + r );
        }
        area = 0;
        sort( sx.begin(), sx.end() );
        sort( sy.begin(), sy.end() );
 
        int a, b, c, flag;
        for( a = 0; a < sx.size() - 1; a++ )
            for( b = 0; b < sy.size() - 1; b++ )
                for( c = flag = 0; c < square.size(); c++) {
                    if( confirm( square[c], coverage( sx[ a ], sx[ a + 1 ], sy[ b ], sy[ b + 1 ] ) ) )
                        if( flag == 0 ) {
                            area += ( sx[ a + 1 ] - sx[ a ] ) * ( sy[ b + 1 ] - sy[ b ] );
							flag++;
						}
                }
        cout << ++order << " " << fixed << setprecision(2) << area << endl;
    }
    
    return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 3208
final_rank: 9

code_snippet: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <cctype>
#include <tuple>

#ifdef _MSC_VER
#include <agents.h>
#endif

#define FOR(i, a, b) for(int i = (a); i < (int)(b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define REV(v) v.rbegin(), v.rend()
#define MEMSET(v, s) memset(v, s, sizeof(v))
#define X first
#define Y second

using namespace std;

const double EPS = 1e-9;

struct Rect{
	double l, t, r, b;
	bool contain(const Rect &rc){
		return l - EPS < rc.l &&
			t - EPS < rc.t &&
			r + EPS > rc.r &&
			b + EPS > rc.b;
	}
	double S(){
		return (r - l)*(b - t);
	}
};

int n;
Rect rect[500];
double x[500], y[500];

int main(){
	cout.setf(ios::fixed);
	cout.precision(2);
	int t = 1;
	while (cin >> n, n){
		rep(i, n){
			double xx, yy, rr;
			cin >> xx >> yy >> rr;
			rect[i] = Rect{ xx - rr, yy - rr, xx + rr, yy + rr };
			x[i * 2] = xx - rr, x[i * 2 + 1] = xx + rr;
			y[i * 2] = yy - rr, y[i * 2 + 1] = yy + rr;
		}
		sort(x, x + 2 * n);
		sort(y, y + 2 * n);

		double ans = 0;
		rep(i, 2 * n - 1) rep(j, 2 * n - 1) {
			Rect r = {x[i], y[j], x[i+1], y[j+1]};
			int cnt = 0;
			rep(k, n){
				if (rect[k].contain(r)) ++cnt;
			}
			if (cnt > 0) ans += r.S();
		}
		cout << t++ << " " <<  ans << endl;
	}

	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 1320
final_rank: 7

code_snippet: //24
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

struct L{
  int y,l,r,f;
  bool operator<(L a)const{
    return y<a.y;
  }
};

int main(){
  int cs=0;
  for(int n;cin>>n,n;){
    L l[200];
    for(int i=0;i<n;i++){
      double x,y,r;
      cin>>x>>y>>r;
      L &a=l[2*i],&b=l[2*i+1];
      a.l=b.l=(x-r)*100+.5+20000;
      a.r=b.r=(x+r)*100+.5+20000;
      a.y=(y-r)*100+.5+20000;
      b.y=(y+r)*100+.5+20000;
      a.f=1;
      b.f=-1;
    }
    sort(l,l+n*2);
    int c[60001]={};
    unsigned sum=0;
    for(int i=0;i<2*n-1;i++){
      for(int j=l[i].l;j<l[i].r;j++){
	c[j]+=l[i].f;
      }
      int h=l[i+1].y-l[i].y;
      sum+=(60001-count(c,c+60001,0U))*h;
    }
    cout.precision(2);
    cout<<++cs<<' '<<fixed<<sum/10000.<<endl;
  }
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 1548
final_rank: 8

code_snippet: #define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <cstdio>
#include <iostream>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P > PP;

int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};

static const double EPS = 1e-8;

class Data{
public:
	double x;
	double y;
	double r;
	Data(double _x,double _y,double _r){
		x = _x;
		y = _y;
		r = _r;
	}
};

bitset<10000> found; 
bool filled[400][400];
int main(){
	int n;
	int idx = 1;
	while(~scanf("%d",&n)){
		if(n==0) break;

		vector<Data> Points;
		memset(filled,0,sizeof(filled));

		for(int i=0;i<n;i++){
			double x,y,r;
			scanf("%lf %lf %lf",&x,&y,&r);
			Points.push_back(Data(x,y,r));

			//x=200; cx=20000;
			//x=0 cx=0;
			//r=200 ra=20000;
			//-20000<square<20000

			int cx = x*100.0;
			int cy = y*100.0;
			int ra = r*100.0; 
			
			for(int y=0;y<40000;y+=100){
				for(int x=0;x<40000;x+=100){
					if(cx - ra + 20000 <= x && x+100 < cx+ra + 20000
					&& cy - ra + 20000 <= y && y+100 < cy+ra + 20000){
						filled[y/100][x/100] = true;
						continue;
					}
				}
			}
		}


		int res=0;


		for(int y=0;y<40000;y+=100){
			for(int x=0;x<40000;x+=100){
				if(filled[y/100][x/100]){
					res+= 10000;
					continue;
				}
				else{

					found.reset();
					for(int i=0;i<Points.size();i++){
						int cx = Points[i].x*100.0 + 20000;
						int cy = Points[i].y*100.0 + 20000;
						int ra = Points[i].r*100.0;


						if(cx+ra < x || x+100 <= cx - ra) continue;
						if(cy+ra < y || y+100 <= cy - ra) continue;
						for(int dy= max(cy-ra,y);dy<min(cy+ra,y+100);dy++){
							for(int dx = max(cx-ra,x);dx < min(cx+ra,x+100); dx++){
								found[(dy-y)*100+(dx-x)] = true;
							}
						}

					}

					res += found.count();

				}

			}
		}

		printf("%d %.2lf\n",idx++,res/(double)10000);		
	}
}
accuracy: 1
time_ms: 940
memory_kb: 1420
final_rank: 12

code_snippet: #include <cstdio>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <sstream>
#include <stack>

using namespace std;

const double EPS=(1e-10);
typedef long long ll;
typedef pair<int,int> pii;
typedef complex<double> P;
typedef pair<P,P> Rect;

bool EQ(double a,double b){
  return abs((a)-(b))<EPS;
}
void fast_stream(){
  std::ios_base::sync_with_stdio(0);
}

const int INF=1000000000;
int N;

class Event{
public:
  double y;
  bool isIn;
  int id;
  Event(){}
  Event(double y_,bool isIn_,int id_){
    y=y_;
    isIn=isIn_;
    id=id_;
  }
  bool operator<(const Event& e)const{
    return e.y>this->y; 
  }
};
Event evs[1001];
Rect recs[1001];

class UnionFindTree{
public:
  // indexÌÌem[h( éWÌeð©Â¯½¢Æ«Í±±ð¼ÚQÆ¹¸Afindðg¤)
  vector<int> par;
  // indexðªÆ·éØÌN
  vector<int> rank;
  vector<double> ls,rs;
  // ØÌÅål
  int treeSize;
public:
  UnionFindTree(int initTreeSize = 1000){
    // øÅ^¦çê½lðÅåi[Æ·éUnionFindTreeÌì¬
    treeSize = initTreeSize;
    init();
  }
  void init(){
    for(int i = 0; i < treeSize; i++){
      par.push_back(i);
      rank.push_back(0);
      ls.push_back(0);
      rs.push_back(0);
    }
  }
  // ^¦çê½ªi[³êÄ¢éØÌ[gðTõ
  int find(int x){  
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
  }
  // aWðÆéB½¾µ±±ÅÍeWÌeÌt¯Ö¦ÍN±çÈ¢
  void unite(int x,int y,double l,double r){
    x = find(x);
    y = find(y);
    if(x == y)return;
    if(rank[x] < rank[y])par[x] = y;
    else{
      par[y] = x;
      if(rank[y] == rank[x])rank[x]++;
    }
    int p=find(x);
    ls[p]=l;
    rs[p]=r;
  }
  bool same(int x,int y){
    return find(x) == find(y);
  }
};

int main(){
  int cnt=0;
  while(cin>>N&&N){
    int NN=0;
    for(int i=0;i<N;i++){
      double x,y,r;
      cin>>x>>y>>r;
      recs[i].first=P(x-r,y-r);
      recs[i].second=P(x+r,y+r);
      if(EQ(r,0))continue;
      evs[2*NN]=Event(y-r,true,i);
      evs[2*NN+1]=Event(y+r,false,i);
      NN++;
    }
    sort(evs,evs+2*NN);
    double prvy=-INF;
    double sumLen=0;
    double res=0;
    vector<int> v;
    // yÌ¬³¢ÔÉCxgð
    for(int k=0;k<2*NN;k++){
      Event &e=evs[k];
      if(!EQ(prvy,-INF))res+=sumLen*(e.y-prvy);
      prvy=e.y;
      // _ÌÇÁAí
      if(e.isIn)v.push_back(e.id);
      else v.erase(find(v.begin(),v.end(),e.id));
      // ¡ñÌ¡ðvZ
      UnionFindTree uft(v.size());
      for(int i=0;i<v.size();i++){
	uft.ls[i]=recs[v[i]].first.real();
	uft.rs[i]=recs[v[i]].second.real();
      }
      for(int i=0;i<v.size();i++){
	for(int j=i+1;j<v.size();j++){
	  // ÍÍª©Ôéæ¤ÈçÎAunite
	  if((EQ(uft.rs[uft.find(i)]
		 ,uft.ls[uft.find(j)])
	      ||(uft.rs[uft.find(i)]
		 >uft.ls[uft.find(j)]))
	     &&(EQ(uft.ls[uft.find(i)]
		   ,uft.rs[uft.find(j)])
		||(uft.ls[uft.find(i)]
		   <uft.rs[uft.find(j)]))){
	    double minx=min(uft.ls[uft.find(i)]
			    ,uft.ls[uft.find(j)]);
	    double maxx=max(uft.rs[uft.find(i)]
			    ,uft.rs[uft.find(j)]);
	    uft.unite(i,j,minx,maxx);
	  }
	}
      }
      set<int> s;
      for(int i=0;i<v.size();i++)
	s.insert(uft.find(i));
      sumLen=0;
      for(set<int>::iterator it
	    =s.begin();it!=s.end();it++){
	sumLen+=(uft.rs[*it]-uft.ls[*it]);
      }
    }
    cnt++;
    printf("%d %.2f\n",cnt,res);
  }

  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1

code_snippet: #include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;

struct R
{
	double x1,x2,y1,y2;
	R(double x1,double x2,double y1,double y2):x1(x1),x2(x2),y1(y1),y2(y2){}
};
bool F(const R &a,const R &b)
{
	return(a.x1<b.x2&&b.x1<a.x2&&a.y1<b.y2&&b.y1<a.y2);
}
int main()
{
	int n,i,j,k,T=0;
	double x,y,p,res;
	while(scanf("%d",&n),n)
	{
		vector<R>v;
		vector<double>vx,vy;
		while(n--)
		{
			scanf("%lf%lf%lf",&x,&y,&p);
			v.push_back(R(x-p,x+p,y-p,y+p));
			vx.push_back(x-p);
			vx.push_back(x+p);
			vy.push_back(y-p);
			vy.push_back(y+p);
		}
		int f;
		res=0;
		sort(vx.begin(),vx.end());
		sort(vy.begin(),vy.end());

		for(i=0;i+1<vx.size();++i)
			for(j=0;j+1<vy.size();++j)
				for(f=k=0;k<v.size();++k)
					if(F(v[k],R(vx[i],vx[i+1],vy[j],vy[j+1])))
						if(f++==0)
							res+=(vx[i+1]-vx[i])*(vy[j+1]-vy[j]);
		printf("%d %.2f\n",++T,res);
	}
	return 0;
}
accuracy: 1
time_ms: 90
memory_kb: 0
final_rank: 4

code_snippet: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    int sequenceNum = 0;
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<double> x(2*n), y(2*n), x1(n), y1(n), x2(n), y2(n);
        for(int i=0; i<n; ++i){
            double x0, y0, r;
            cin >> x0 >> y0 >> r;
            x[2*i] = x1[i] = x0 - r;
            x[2*i+1] = x2[i] = x0 + r;
            y[2*i] = y1[i] = y0 - r;
            y[2*i+1] = y2[i] = y0 + r;
        }
        sort(x.begin(), x.end());
        sort(y.begin(), y.end());

        double ret = 0.0;
        for(int i=0; i<2*n-1; ++i){
            for(int j=0; j<2*n-1; ++j){
                for(int k=0; k<n; ++k){
                    if(x1[k] <= x[i] && x[i+1] <= x2[k] && y1[k] <= y[j] && y[j+1] <= y2[k]){
                        ret += (y[j+1] - y[j]) * (x[i+1] - x[i]);
                        break;
                    }
                }
            }
        }
        printf("%d %.02f\n", ++sequenceNum, ret);
    }
}
accuracy: 1
time_ms: 40
memory_kb: 988
final_rank: 5

code_snippet: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double EPS = 1.0e-10;

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
};

int main()
{
    int sequenceNum = 0;
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<double> x(2*n), y(2*n);
        vector<Point> p1(n), p2(n);
        for(int i=0; i<n; ++i){
            double x0, y0, r;
            cin >> x0 >> y0 >> r;
            x[2*i] = p1[i].x = x0 - r;
            x[2*i+1] = p2[i].x = x0 + r;
            y[2*i] = p1[i].y = y0 - r;
            y[2*i+1] = p2[i].y = y0 + r;
        }
        sort(x.begin(), x.end());
        sort(y.begin(), y.end());

        double ret = 0.0;
        for(int i=0; i<2*n-1; ++i){
            for(int j=0; j<2*n-1; ++j){
                for(int k=0; k<n; ++k){
                    if(p1[k].x <= x[i] && x[i+1] <= p2[k].x && p1[k].y <= y[j] && y[j+1] <= p2[k].y){
                        ret += (y[j+1] - y[j]) * (x[i+1] - x[i]);
                        break;
                    }
                }
            }
        }
        printf("%d %.02f\n", ++sequenceNum, ret);
    }
}
accuracy: 1
time_ms: 40
memory_kb: 988
final_rank: 5

code_snippet: #include <iostream>
#include <vector>
#include <cstdio>
#include <complex>
#include <algorithm>
using namespace std;
double unit = 0.001;
typedef complex<double> P;
#define rep(i,n) for(int i=0;i<n;i++)

bool cmp(const pair<P,P>&a,const pair<P,P>&b){
	return a.first.imag() < b.first.imag();
}
int main(){
	int n,N=0;
	while(cin >> n ,n){
		vector< pair<P,P> > data;
		double ans = 0;
		rep(i,n){
			double a,b,r;
			cin >> a >> b >> r;
			data.push_back(make_pair(P(a-r,b-r),P(a+r,b+r)));
		}
		sort(data.begin(),data.end(),cmp);
		for(double x=-200;x<=400;x += unit){
			vector< pair<double,double> > L;
			rep(i,n){
				if(data[i].first.real() <= x && x <= data[i].second.real()){
					L.push_back(make_pair(data[i].first.imag(),data[i].second.imag()));
				}
			}
			if(L.size() == 0)continue;
			double sz = 0;
			double cs = L[0].first, ce = L[0].second;		
			for(int i=1;i<L.size();i++){
				if(L[i].first <= ce)ce = max(ce,L[i].second);
				else sz += ce-cs , cs = L[i].first , ce = L[i].second;
			}
			sz += ce-cs;
			ans += sz * unit;
		}
		printf("%d %.2lf\n",++N,ans);
	}
 
}
accuracy: 1
time_ms: 660
memory_kb: 988
final_rank: 10

code_snippet: #include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<complex>

#define START 0
#define END 1
using namespace std;

typedef complex<double> point;

const double infty = 1e40;
const double eps = 1e-10;

bool eq(double a, double b){
  return abs(b-a) < eps;
}

struct anntena{
  point ul, rd;
  anntena(point a, point b):ul(a),rd(b){}
  bool isinside(const point &t){
    if( ul.real()<=t.real()&&t.real()<=rd.real()&&
	ul.imag()>=t.imag()&&t.imag()>=rd.imag())return true;
    return false;
  }
};

int main()
{
  int n;
  int tc=1;
  while(cin>>n && n>0){
    double res = 0;
    set<double> X;
    set<double> Y;
    vector<anntena> va;

    for(int i = 0; i < n; ++i){
      double x,y,r;
      scanf("%lf%lf%lf", &x, &y, &r);
      X.insert(x-r);
      X.insert(x+r);
      Y.insert(y-r);
      Y.insert(y+r);
      va.push_back( anntena(point(x-r,y+r), point(x+r,y-r) ) );
    }
    for(set<double>::iterator itx = X.begin(); itx != X.end(); ++itx){

      double x = *itx;
      ++itx;
      if(itx==X.end())break;
      double nx = *itx;
      --itx;
      double span_x = nx - x;
      for(set<double>::iterator ity = Y.begin(); ity != Y.end(); ++ity){
	double y = *ity;
	++ity;
	if(ity==Y.end())break;
	double ny = *ity;
	--ity;
	double span_y = ny - y;
	point cent = point((x+nx)/2,(y+ny)/2);
	bool cent_cont = false;
	for(int i = 0; i < (int)va.size(); ++i){
	  if( va[i].isinside( cent ) ) cent_cont = true;
	}
	if( cent_cont ){
	  res += span_x * span_y;
	}
      } 
    }
    printf("%d %.2lf\n", tc, res);
    ++tc;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1

code_snippet: #include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<map>
#include<complex>

#define START 0
#define END 1
using namespace std;

typedef complex<double> point;

const double infty = 1e40;
const double eps = 1e-10;

bool eq(double a, double b){
  return abs(b-a) < eps;
}

struct anntena{
  point ul, rd;
  anntena(point a, point b):ul(a),rd(b){}
  bool isinside(const point &t){
    if( ul.real()<=t.real()&&t.real()<=rd.real()&&
	ul.imag()>=t.imag()&&t.imag()>=rd.imag())return true;
    return false;
  }
};

int main()
{
  int n;
  int tc=1;
  while(cin>>n && n>0){
    double res = 0;
    set<double> X;
    set<double> Y;
    vector<anntena> va;

    for(int i = 0; i < n; ++i){
      double x,y,r;
      scanf("%lf%lf%lf", &x, &y, &r);
      //cin >> x >> y >> r;
      X.insert(x-r);
      X.insert(x+r);
      Y.insert(y-r);
      Y.insert(y+r);
      va.push_back( anntena(point(x-r,y+r), point(x+r,y-r) ) );
    }
    for(set<double>::iterator itx = X.begin(); itx != X.end(); ++itx){

      double x = *itx;
      ++itx;
      if(itx==X.end())break;
      double nx = *itx;
      --itx;
      double span_x = nx - x;
      for(set<double>::iterator ity = Y.begin(); ity != Y.end(); ++ity){
	double y = *ity;
	++ity;
	if(ity==Y.end())break;
	double ny = *ity;
	--ity;
	double span_y = ny - y;
	/*
	point lu = point(x,ny);
	point ru = point(nx,ny);
	point ld = point(x,y);
	point rd = point(nx,y);
	*/
	point cent = point((x+nx)/2,(y+ny)/2);
	//bool lu_cont = false;
	//bool rd_cont = false;
	bool cent_cont = false;
	for(int i = 0; i < (int)va.size(); ++i){
	  if( va[i].isinside( cent ) ) cent_cont = true;
	  //if( va[i].isinside( rd ) ) rd_cont = true;
	}
	if( cent_cont ){//&& rd_cont ){
	  res += span_x * span_y;
	}
      } 
    }
    printf("%d %.2lf\n", tc, res);
    ++tc;
  }
  return 0;
}
accuracy: 1
time_ms: 10
memory_kb: 0
final_rank: 1