QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#355393#5106. Islands from the Skyucup-team052#WA 14ms3948kbC++232.2kb2024-03-16 16:55:162024-03-16 16:55:18

Judging History

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

  • [2024-03-16 16:55:18]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:3948kb
  • [2024-03-16 16:55:16]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define double long double
const double eps=1e-9;
const double PI=acos(-1);
int sgn(double x)
{
	if(x>=eps) return 1;
	else if(x<-eps) return -1;
	return 0;
}
struct Vec
{
	double x,y;
	Vec(double a=0,double b=0) {x=a,y=b;}
	double norm() {return sqrt(x*x+y*y);}
};
Vec operator + (const Vec &x,const Vec &y) {return Vec(x.x+y.x,x.y+y.y);}
Vec operator - (const Vec &x,const Vec &y) {return Vec(x.x-y.x,x.y-y.y);}
Vec operator * (const Vec &x,const double &y) {return Vec(x.x*y,x.y*y);}
double cross(const Vec &x,const Vec &y) {return x.x*y.y-x.y*y.x;}
Vec norm(Vec x,double r)
{
	r/=x.norm();
	return x*r;
}
#define N 105
vector<Vec> a[N];
double S[N];
int n,m;
Vec b[N],c[N]; double z1[N],z2[N];
int vis[N];
double Area(const vector<Vec> &v)
{
	double sum=0;
	for(int j=1;j+1<(int)v.size();j++) sum+=cross(v[0]-v[j],v[0]-v[j+1]);
	return sum;
}
int chk(double theta)
{
	for(int i=1;i<=n;i++) vis[i]=0;
	for(int i=1;i<=m;i++)
	{
		double r1=z1[i]*tan(theta),r2=z2[i]*tan(theta);
		Vec v=c[i]-b[i];
		Vec trans(-v.y,v.x);
		vector<Vec> out(4);
		out[0]=b[i]+norm(trans,r1);
		out[1]=b[i]-norm(trans,r1);
		out[2]=c[i]-norm(trans,r2);
		out[3]=c[i]+norm(trans,r2);
		double area=Area(out);
		auto inside=[&](Vec v)
		{
			double sum=0;
			sum+=abs(cross(v-out[0],v-out[1]));
			sum+=abs(cross(v-out[1],v-out[2]));
			sum+=abs(cross(v-out[2],v-out[3]));
			sum+=abs(cross(v-out[3],v-out[0]));
			return sgn(sum-area)==0;
		};
		for(int j=1;j<=n;j++)
		{
			int ok=1;
			for(Vec v:a[j]) ok&=inside(v);
			if(ok) vis[j]=1;
		}
	}
	for(int i=1;i<=n;i++) if(!vis[i]) return 0;
	return 1;
}
signed main()
{
#ifdef xay5421
	freopen("a.in","r",stdin);
#endif	
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		int s; scanf("%d",&s);
		a[i].resize(s);
		for(int j=0;j<s;j++) scanf("%Lf %Lf",&a[i][j].x,&a[i][j].y);
		S[i]=Area(a[i]);
	}
	for(int i=1;i<=m;i++) scanf("%Lf %Lf %Lf %Lf %Lf %Lf",&b[i].x,&b[i].y,&z1[i],&c[i].x,&c[i].y,&z2[i]);
	double l=0,r=PI/2;
	for(int it=1;it<=100;it++)
	{
		double mid=(l+r)/2;
		if(chk(mid)) r=mid;
		else l=mid;
	}
	if(r==PI/2) printf("impossible\n");
	else printf("%.10Lf\n",l/PI*180);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3948kb

input:

1 1
3
-5 0
5 0
0 5
-10 10 10 10 10 10

output:

44.9999999999

result:

ok 

Test #2:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

1 1
3
-5 0
5 0
0 5
-10 0 10 10 0 10

output:

26.5650511770

result:

ok 

Test #3:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

1 1
3
-5 0
5 0
0 5
0 10 10 10 0 10

output:

46.6861433416

result:

ok 

Test #4:

score: 0
Accepted
time: 0ms
memory: 3940kb

input:

1 1
3
-5 0
5 0
0 5
0 10 5 10 0 10

output:

59.4910411337

result:

ok 

Test #5:

score: 0
Accepted
time: 0ms
memory: 3880kb

input:

1 1
3
-5 0
5 0
0 5
0 10 20 -10 0 10

output:

31.2196984473

result:

ok 

Test #6:

score: 0
Accepted
time: 0ms
memory: 3896kb

input:

1 3
3
-5 0
5 0
0 5
-10 0 25 10 0 20
-5 10 10 10 -5 20
-4 1 100 5 10 100

output:

12.5288077091

result:

ok 

Test #7:

score: 0
Accepted
time: 1ms
memory: 3888kb

input:

1 2
4
0 0
20 0
20 40
0 40
-10 30 30 30 30 30
-10 10 30 30 10 30

output:

45.0000000000

result:

ok 

Test #8:

score: 0
Accepted
time: 1ms
memory: 3876kb

input:

1 4
4
0 0
20 0
20 40
0 40
-10 30 30 30 30 30
-10 20 30 30 20 30
-10 10 30 30 10 30
10 -10 30 10 50 30

output:

18.4349488229

result:

ok 

Test #9:

score: 0
Accepted
time: 1ms
memory: 3916kb

input:

1 2
4
0 0
40 0
40 40
0 40
10 10 10 20 20 20
30 10 10 10 30 20

output:

impossible

result:

ok 

Test #10:

score: 0
Accepted
time: 0ms
memory: 3888kb

input:

1 3
4
0 0
20 0
20 40
0 40
-10 30 30 15 30 30
5 30 30 30 30 30
1 50 30 21 50 30

output:

impossible

result:

ok 

Test #11:

score: 0
Accepted
time: 0ms
memory: 3908kb

input:

1 1
4
0 0
40 0
40 40
0 40
-100 -100 20 100 100 10

output:

63.6657521531

result:

ok 

Test #12:

score: 0
Accepted
time: 0ms
memory: 3920kb

input:

1 4
4
-10 -10
10 -10
10 10
-10 10
-100 0 10 100 0 10
0 100 10 0 -100 10
50 50 15 -50 -50 15
-50 50 15 50 -50 15

output:

43.3138566583

result:

ok 

Test #13:

score: -100
Wrong Answer
time: 14ms
memory: 3912kb

input:

1 100
100
822286 0
856789 53904
986567 124632
629039 119995
732157 187986
691605 224716
728650 288493
591087 278144
801573 440668
425257 269876
614456 446428
424157 350893
645680 606334
406524 432904
545628 659551
359831 495265
367048 578376
251435 457360
319990 680014
336526 849968
214009 658652
23...

output:

impossible

result:

wrong answer