QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#355528#5106. Islands from the Skyucup-team052AC ✓399ms4428kbC++232.4kb2024-03-16 19:23:152024-03-16 19:23:17

Judging History

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

  • [2024-03-16 19:23:17]
  • 评测
  • 测评结果:AC
  • 用时:399ms
  • 内存:4428kb
  • [2024-03-16 19:23:15]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
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);
		/*
		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;
		};
		*/
		auto inside=[&](Vec v)
		{
			int fl0=sgn(cross(out[0]-out[1],out[0]-v));
			int fl1=sgn(cross(out[1]-out[2],out[1]-v));
			int fl2=sgn(cross(out[2]-out[3],out[2]-v));
			int fl3=sgn(cross(out[3]-out[0],out[3]-v));
			if(fl0>=0&&fl1>=0&&fl2>=0&&fl3>=0) return 1;
			if(fl0<=0&&fl1<=0&&fl2<=0&&fl3<=0) return 1;
			return 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()
{
	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;
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 4132kb

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: 4140kb

input:

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

output:

26.5650511768

result:

ok 

Test #3:

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

input:

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

output:

46.6861433415

result:

ok 

Test #4:

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

input:

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

output:

59.4910411336

result:

ok 

Test #5:

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

input:

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

output:

31.2196984472

result:

ok 

Test #6:

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

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.5288077090

result:

ok 

Test #7:

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

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: 0ms
memory: 4200kb

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: 4ms
memory: 4304kb

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: 4ms
memory: 4428kb

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: 4244kb

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: 4172kb

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: 0
Accepted
time: 5ms
memory: 4136kb

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:

53.7906384311

result:

ok 

Test #14:

score: 0
Accepted
time: 9ms
memory: 4340kb

input:

100 1
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 482...

output:

impossible

result:

ok 

Test #15:

score: 0
Accepted
time: 6ms
memory: 4272kb

input:

100 1
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 482...

output:

33.6907956097

result:

ok 

Test #16:

score: 0
Accepted
time: 6ms
memory: 4420kb

input:

100 1
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 482...

output:

66.4027966421

result:

ok 

Test #17:

score: 0
Accepted
time: 399ms
memory: 4280kb

input:

100 100
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 4...

output:

4.1890016471

result:

ok 

Test #18:

score: 0
Accepted
time: 44ms
memory: 4276kb

input:

100 11
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 48...

output:

32.4119284772

result:

ok 

Test #19:

score: 0
Accepted
time: 370ms
memory: 4244kb

input:

100 90
100
461002 481444
460618 481480
460584 481512
460833 481595
460670 481605
460545 481607
460942 481801
460526 481672
460912 481923
460765 481903
460505 481781
460430 481766
460589 481959
460593 482032
460477 481972
460440 481994
460510 482183
460285 481888
460387 482179
460246 481963
460303 48...

output:

5.5754489360

result:

ok 

Extra Test:

score: 0
Extra Test Passed