QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#465682 | #9103. Zayin and Fireball | Qingyu | WA | 1ms | 4236kb | C++ | 4.9kb | 2024-07-07 04:35:36 | 2024-09-23 15:03:46 |
Judging History
answer
#include<stdio.h>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std;
#define pb(a) push_back(a)
#define fi first
#define se second
#define mp(a,b) make_pair(a,b)
typedef double type;
const type eps=1e-8,pi=acosl(-1);
inline type Sqrt(type x) {
return x<0?0:sqrtl(x);
}
inline type pow(type x) {
return x*x;
}
inline int dcmp(type x) {
return (x>eps)-(x<-eps);
}
struct point {
type x,y;
point() {}
point(type x,type y):x(x),y(y) {}
friend bool operator == (const point &a,const point &b) {
return dcmp(a.x-b.x)==0 && dcmp(a.y-b.y)==0;
}
friend bool operator < (const point &a,const point &b) {
return a.x<b.x || a.x==b.x && a.y<b.y;
}
friend point operator + (const point &a,const point &b) {
return point(a.x+b.x,a.y+b.y);
}
friend point operator - (const point &a,const point &b) {
return point(a.x-b.x,a.y-b.y);
}
friend point operator *(const point &a,const type &b) {
return point(a.x*b,a.y*b);
}
friend point operator / (const point &a,const type &b) {
return point(a.x/b,a.y/b);
}
};
inline type dis(const point &a,const point &b) {
return Sqrt(pow(a.x-b.x)+pow(a.y-b.y));
}
inline point rotate(const point &p,type cost,type sint) {
return point(p.x*cost-p.y*sint,p.x*sint+p.y*cost);
}
inline pair<point,point> crosspoint(point ap,type ar,point bp,type br) {
type d=dis(ap,bp);
type cost=(pow(ar)+pow(d)-pow(br))/(2*ar*d);
type sint=Sqrt(1.-pow(cost));
point v=(bp-ap)/d*ar;
return make_pair(ap+rotate(v,cost,-sint),ap+rotate(v,cost,sint));
}
struct rd {
point O,o;
type D,d;
}R[505];
inline type atan2(const point &a) {
return atan2l(a.y,a.x);
}
inline pair<point,point> cp(const point &o,type R,const point &O,type d) {
pair<point,point> pr=crosspoint(o,R,O,d);
point a=pr.first,b=pr.second;
type ta=atan2(a-o),tb=atan2(b-o);
if (tb<ta) tb+=2*pi;
type mid=(ta+tb)/2;
point mp=o+point(R*cosl(mid),R*sinl(mid));
if (dis(mp,O)-eps>d) {
swap(a,b);
swap(ta,tb);
}
return make_pair(a,b);
}
vector<pair<type,int> > tmp,tmpinte;
inline void push(type l,type r,vector<pair<type,int> > &tmp,int del=1) {
if (l<r+eps) {
tmp.push_back(make_pair(l,del));
tmp.push_back(make_pair(r,-del));
}
else {
tmp.push_back(make_pair(l,del));
tmp.push_back(make_pair(pi,-del));
tmp.push_back(make_pair(-pi,del));
tmp.push_back(make_pair(r,-del));
}
}
inline void cal(const point &o,type R,const rd &A) {
bool outer,inner;
type D=dis(o,A.O),d=dis(o,A.o);
outer=(fabsl(D-A.D)<R-eps && R+eps<D+A.D);
inner=(fabsl(d-A.d)<R-eps && R+eps<d+A.d);
if (!inner && !outer) {
if ((d+A.d<R+eps || R+A.d<d+eps) && R+D<A.D+eps) push(-pi,pi,tmpinte);
}
if (inner && !outer) if (R+D<A.D+eps) {
pair<point,point> p=cp(o,R,A.o,A.d);
point a=p.first,b=p.second;
type ta=atan2(a-o),tb=atan2(b-o);
push(tb,ta,tmpinte);
}
if (!inner && outer) if (A.d+eps<R+d) {
pair<point,point> p=cp(o,R,A.O,A.D);
point a=p.first,b=p.second;
type ta=atan2(a-o),tb=atan2(b-o);
push(ta,tb,tmpinte);
}
if (inner && outer) {
tmp.clear();
pair<point,point> p1=cp(o,R,A.o,A.d);
point a1=p1.first,b1=p1.second;
type ta1=atan2(a1-o),tb1=atan2(b1-o);
push(ta1,tb1,tmp,-1);
pair<point,point> p2=cp(o,R,A.O,A.D);
point a2=p2.first,b2=p2.second;
type ta2=atan2(a2-o),tb2=atan2(b2-o);
push(ta2,tb2,tmp);
sort(tmp.begin(),tmp.end());
tmp.push_back(make_pair(pi,0));
type lst=-pi;
int now=0;
for (auto v:tmp) {
if (now>0 && lst+eps<v.first) push(lst,v.first,tmpinte);
lst=v.first;
now+=v.second;
}
}
}
inline type inte(int i,int op,int n) {
tmpinte.clear();
point o=R[i].o,O=R[i].O;
type d=R[i].d,D=R[i].D;
if (op==0) {
for (int j=1;j<=n;j++) if (i!=j) cal(O,D,R[j]);
type Dis=dis(o,O);
if (fabsl(Dis-D)+eps<d && d+eps<Dis+D){
pair<point,point> p=cp(O,D,o,d);
point a=p.first,b=p.second;
type ta=atan2(a-O),tb=atan2(b-O);
push(ta,tb,tmpinte);
}
if (Dis+D<d+eps) push(-pi,pi,tmpinte);
}
else {
for (int j=1;j<=n;j++) if (i!=j) cal(o,d,R[j]);
type Dis=dis(o,O);
if (fabsl(Dis-D)+eps<d && d+eps<Dis+D){
pair<point,point> p=cp(o,d,O,D);
point a=p.first,b=p.second;
type ta=atan2(a-o),tb=atan2(b-o);
push(tb,ta,tmpinte);
}
if (Dis+D<d+eps || D+d<Dis+eps) push(-pi,pi,tmpinte);
}
sort(tmpinte.begin(),tmpinte.end());
tmpinte.push_back(make_pair(pi,0));
type lst=-pi,rt=0;
int now=0;
for (auto v:tmpinte) {
if (!now) rt+=(op==0)?O.y*D*(cosl(v.first)-cosl(lst))-pow(D)/2*(v.first-lst)+pow(D)/4*(sinl(2*v.first)-sinl(2*lst))
:o.y*d*(cosl(v.first)-cosl(lst))-pow(d)/2*(v.first-lst)+pow(d)/4*(sinl(2*v.first)-sinl(2*lst));
lst=v.first;
now+=v.second;
}
return rt;
}
inline void solve() {
int n;
scanf("%d",&n);
for (int i=1;i<=n;i++) {
double x,y,X,Y,D,d;
scanf("%lf%lf%lf%lf%lf%lf",&X,&Y,&D,&x,&y,&d);
R[i]=(rd){point(X,Y),point(x,y),D,d};
}
type ans=0;
for (int i=1;i<=n;i++) ans-=inte(i,0,n);
for (int i=1;i<=n;i++) ans+=inte(i,1,n);
printf("%.6lf\n",double(ans));
}
int main() {
int T;
scanf("%d",&T);
for (int t=1;t<=T;t++) solve();
}
详细
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 4236kb
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.000000 9.424778 9.424778 11.163304 3.957934 18.849556 28.274334 36.296045 28.274334 28.274334 28.157137 417.831823 38.218848 125660.564551 125660.564551 125660.564789 125660.564789 31412.784943 78.317303 301.267454 18751.965611 70.914255
result:
wrong answer 19th numbers differ - expected: '39.57934', found: '78.31730', error = '0.97874'