QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#356471 | #5106. Islands from the Sky | InfinityNS | AC ✓ | 11ms | 4300kb | C++14 | 3.8kb | 2024-03-17 20:44:12 | 2024-03-17 20:44:12 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ldb long double
#define pb push_back
struct pt{
ldb x,y;
pt():x(0),y(0){}
pt(ldb a,ldb b):x(a),y(b){}
};
pt operator - (pt a,pt b){return pt(a.x-b.x,a.y-b.y);}
pt operator + (pt a,pt b){return pt(a.x+b.x,a.y+b.y);}
pt operator * (pt a,ldb b){return pt(a.x*b,a.y*b);}
pt operator / (pt a,ldb b){return pt(a.x/b,a.y/b);}
ldb dot(pt a,pt b){return a.x*b.x+a.y*b.y;}
ldb abs(pt a){return sqrt(dot(a,a));}
ldb cross(pt a,pt b){return a.x*b.y-a.y*b.x;}
pt norm(pt a){return a/abs(a);}
pt perp(pt a){return pt(-a.y,a.x);}
const int N=105;
vector<pt> poly[N];
pt from[N],to[N];
int fromZ[N],toZ[N];
pt trapez[N][4];
const ldb PI=acos(-1);
const ldb eps=1e-8;
bool ins(int i,pt p){
bool hi=false;
bool lo=false;
for(int j=0;j<4;j++){
ldb cr=cross(trapez[i][j]-p,trapez[i][(j+1)%4]-p);
if(cr<-eps)lo=true;
if(cr>eps)hi=true;
}
return !lo || !hi;
}
bool Check(ldb ang,int n,int m){
for(int i=1;i<=m;i++){
pt dir=to[i]-from[i];
pt v=norm(perp(dir));
ldb len1=tan(ang)*fromZ[i];
trapez[i][0]=from[i]+v*len1;
trapez[i][1]=from[i]-v*len1;
ldb len2=tan(ang)*toZ[i];
trapez[i][2]=to[i]-v*len2;
trapez[i][3]=to[i]+v*len2;
}
for(int i=1;i<=n;i++){
bool inside=false;
for(int j=1;j<=m;j++){
bool ok=true;
for(pt p:poly[i]){
if(!ins(j,p)){
ok=false;
break;
}
}
if(ok){
inside=true;
break;
}
}
if(!inside)return false;
}
return true;
}
#define ll long long
struct pt2{
ll x,y;
pt2():x(0),y(0){}
pt2(ll a,ll b):x(a),y(b){}
};
pt2 operator - (pt2 a,pt2 b){return pt2(a.x-b.x,a.y-b.y);}
pt2 operator + (pt2 a,pt2 b){return pt2(a.x+b.x,a.y+b.y);}
ll cross(pt2 a,pt2 b){return a.x*b.y-a.y*b.x;}
pt2 perp(pt2 a){return pt2(-a.y,a.x);}
bool Possible(int n,int m){
for(int i=1;i<=n;i++){
bool inside=false;
for(int j=1;j<=m;j++){
pt2 A=pt2(round(from[j].x),round(from[j].y));
pt2 B=pt2(round(to[j].x),round(to[j].y));
pt2 dir=perp(B-A);
ll ca=cross(dir,A);
ll cb=cross(dir,B);
if(ca>cb)swap(ca,cb);
bool ok=true;
for(pt p_:poly[i]){
pt2 p=pt2(round(p_.x),round(p_.y));
ll cr=cross(dir,p);
if(ca<=cr && cr<=cb){
continue;
}else{
ok=false;
break;
}
}
if(ok){
inside=true;
break;
}
}
if(!inside)return false;
}
return true;
}
int main(){
int n,m;
scanf("%i %i",&n,&m);
for(int i=1;i<=n;i++){
int sz;
scanf("%i",&sz);
poly[i].resize(sz);
for(int j=0;j<sz;j++){
int x,y;
scanf("%i %i",&x,&y);
poly[i][j].x=x;
poly[i][j].y=y;
}
}
for(int i=1;i<=m;i++){
int x1,y1,x2,y2;
scanf("%i %i %i %i %i %i",&x1,&y1,&fromZ[i],&x2,&y2,&toZ[i]);
from[i].x=x1;
from[i].y=y1;
to[i].x=x2;
to[i].y=y2;
}
if(Possible(n,m)){
ldb top=90,bot=0;
for(int it=0;it<60;it++){
ldb mid=(top+bot)/2;
//printf("Check %.lf\n",mid);
if(Check(mid/180*PI,n,m)){
top=mid;
}else bot=mid;
}
printf("%.12Lf\n",(top+bot)/2);
}else{
printf("impossible\n");
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3932kb
input:
1 1 3 -5 0 5 0 0 5 -10 10 10 10 10 10
output:
44.999999998568
result:
ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
1 1 3 -5 0 5 0 0 5 -10 0 10 10 0 10
output:
26.565051174786
result:
ok
Test #3:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
1 1 3 -5 0 5 0 0 5 0 10 10 10 0 10
output:
46.686143339810
result:
ok
Test #4:
score: 0
Accepted
time: 0ms
memory: 3928kb
input:
1 1 3 -5 0 5 0 0 5 0 10 5 10 0 10
output:
59.491041132127
result:
ok
Test #5:
score: 0
Accepted
time: 0ms
memory: 3932kb
input:
1 1 3 -5 0 5 0 0 5 0 10 20 -10 0 10
output:
31.219698445675
result:
ok
Test #6:
score: 0
Accepted
time: 0ms
memory: 3984kb
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.528807707938
result:
ok
Test #7:
score: 0
Accepted
time: 0ms
memory: 3924kb
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:
44.999999999761
result:
ok
Test #8:
score: 0
Accepted
time: 0ms
memory: 3852kb
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.434948822636
result:
ok
Test #9:
score: 0
Accepted
time: 0ms
memory: 3852kb
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: 3868kb
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: 3932kb
input:
1 1 4 0 0 40 0 40 40 0 40 -100 -100 20 100 100 10
output:
63.665752153118
result:
ok
Test #12:
score: 0
Accepted
time: 0ms
memory: 3852kb
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.313856658140
result:
ok
Test #13:
score: 0
Accepted
time: 1ms
memory: 3976kb
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.790638431072
result:
ok
Test #14:
score: 0
Accepted
time: 2ms
memory: 4056kb
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: 5ms
memory: 4232kb
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.690795609721
result:
ok
Test #16:
score: 0
Accepted
time: 5ms
memory: 4148kb
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.402796642066
result:
ok
Test #17:
score: 0
Accepted
time: 11ms
memory: 4240kb
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.189001647131
result:
ok
Test #18:
score: 0
Accepted
time: 6ms
memory: 4300kb
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.411928477174
result:
ok
Test #19:
score: 0
Accepted
time: 8ms
memory: 4160kb
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.575448935979
result:
ok
Extra Test:
score: 0
Extra Test Passed