QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#504986#9103. Zayin and FireballXunwuqishi#WA 0ms4104kbC++203.0kb2024-08-04 18:03:102024-09-23 15:04:17

Judging History

你现在查看的是最新测评结果

  • [2024-09-23 15:04:17]
  • 管理员手动重测本题所有提交记录
  • 测评结果:WA
  • 用时:0ms
  • 内存:4104kb
  • [2024-08-04 18:03:11]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:3984kb
  • [2024-08-04 18:03:10]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define Alex ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
#define fi first
#define se second
typedef double db;
typedef pair<db,db> pDD;
const db eps = 1e-8;
const int N = 1e3 + 10;
const int INF = 0x3f3f3f3f;
int n;
db sqr(db x)
{
	return x * x;
}
int sgn(db x)
{
	return fabs(x) < eps ? 0 : x < 0 ? -1 : 1;
}
struct Circle{
	db x,y,r;

	void scan()
	{
		scanf("%lf%lf%lf",&x,&y,&r);
	}
	bool operator < (const Circle &b) const { return r > b.r; }
	db disCircletoCircle(Circle b)
	{
		return hypot(x - b.x,y - b.y);
	}
};
struct CircleUnion{
	vector<Circle> cir;
	vector<pair<db,db> > sta;
	int sze() {
		return cir.size();
	}
	CircleUnion(int n = 0){
		cir.clear();
		cir.resize(n);
	}
	void scan(int n = -1)
	{
		if(n == -1)
		scanf("%d",&n);
		(*this) = CircleUnion(n);
		for(int i = 0;i < n;i++) cir[i].scan();
	}
	void add(Circle c)
	{
		cir.push_back(c);
	}
	Circle& operator[](int x){
		return cir[x];
	}
	db f(db x)
	{
		int top = 0;
		for(int i = 0;i < sze();i++)
		if(fabs(cir[i].x - x) < cir[i].r)
		{
			db len = sqrt(sqr(cir[i].r) - sqr(cir[i].x - x));
			sta[++top] = pDD(cir[i].y - len,cir[i].y + len);
		}
		if(! top) return 0;
		sort(sta.begin() + 1,sta.begin() + top + 1);
		int tmp = 1;
		for(int i = 2;i <= top;i++)
		{
			if(sgn(sta[i].fi - sta[tmp].se) <= 0)
			{
				sta[tmp].se = max(sta[tmp].se,sta[i].se);
			}else
			{
				sta[++tmp] = sta[i];
			}
		}
		top = min(top,tmp);
		db res = 0;
		for(int i = 1;i <= top;i++)
		    res = res + (sta[i].se - sta[i].fi);
		return res;
	}
	db Simpson(db L,db M,db R,db fL,db fM,db fR,int dep)
	{
		db M1 = (L + M) / 2,M2 = (M + R) / 2;
		db fM1 = f(M1),fM2 = f(M2);
		db g1 = (M - L) * (fL + 4 * fM1 + fM) / 6;
		db g2 = (R - M) * (fM + 4 * fM2 + fR) / 6;
		db g = (R - L) * (fL + 4 * fM + fR) / 6;
		if(dep > 1l & fabs(g - g1 - g2) < eps) return g;
		return Simpson(L,M1,M,fL,fM1,fM,dep + 1) + 
		      Simpson(M,M2,R,fM,fM2,fR,dep + 1);
	}
	void Unique()
	{
		int cnt = 0;
		sort(cir.begin(),cir.end());
		for(int i = 0;i < sze();i++)
		{
			int ok = 1;
			for(int j = 0;j < cnt;j++)
			if(cir[i].r + cir[i].disCircletoCircle(cir[j]) <= cir[j].r)
			{
				ok = 0;
				break;
			}
			if(ok) cir[cnt++] = cir[i];
		}
		cir.resize(cnt);
	}
	db gao()
	{
		if(sze() == 0) return 0;
		Unique();
		sta.clear();
		sta.resize(sze() + 5);
		db l = cir[0].x - cir[0].r;
		db r = cir[0].x + cir[0].r;
		for(int i = 1;i < sze();i++)
		{
			l = min(l,cir[i].x - cir[i].r);
			r = max(r,cir[i].x + cir[i].r);
		}
		db  mid = l + (r - l) / 2;
		return Simpson(l,mid,r,f(l),f(mid),f(r),0);
	}
};
signed main()
{
	Alex;
	int _;
	std::cin>>_;
	while(_--)
	{
		int n;
		std::cin>>n;
		db s1 = 0.00,s2 = 0.00;
		for(int i = 1;i <= n;i++)
	    {
		    CircleUnion cu; 
		    cu.scan(n);
		    cu.scan(n);
		    s1 = cu.gao();
		    printf("%.8f\n",cu.gao());
	    }
	    printf("%.8f\n",s1 - s2);
	}
	return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 4104kb

input:

22
1
0 0 1 0 0 1
1
0 0 2 0 0 1
1
0 0 2 1 0 1
1
0 0 2 2 0 1
1
0 0 2 1 0 2
2
0 0 1 0 0 0
0 0 3 0 0 2
2
0 0 1 0 0 0
0 0 3 0 0 1
2
-233 0 3 -234 0 1
233 0 2 231 0 1
2
0 0 1 0 0 0
1 0 3 0 0 1
2
0 0 1 0 0 0
0 2 3 0 0 1
2
2 4 2 2 4 1
3 3 3 3 3 1
4
0 1 1 0 2 2
3 3 3 3 4 2
250 2 4 0 0 100
255 7 12 254 10 4
3...

output:

0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.00000000
0.0...

result:

wrong answer 2nd numbers differ - expected: '9.42478', found: '0.00000', error = '1.00000'