QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#390037 | #5106. Islands from the Sky | 0_GB_RAM# | AC ✓ | 1896ms | 4692kb | C++23 | 3.9kb | 2024-04-15 00:42:50 | 2024-04-15 00:42:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define int ll
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define all(x) begin(x),end(x)
#define sz(x) (int)((x).size())
using pii=pair<int,int>;
using vi=vector<int>;
#define fi first
#define se second
#define pb push_back
const int N=110;
vector<pii> polys[N];
pair<array<int,3>,array<int,3>> paths[N];
bool okok[N][N],ok[N];
bool small(pair<double,double> a,pair<double,double> b,pair<double,double> c)
{
a.fi-=b.fi;
a.se-=b.se;
c.fi-=b.fi;
c.se-=b.se;
return a.fi*c.se-a.se*c.fi>=0;
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
cin.exceptions(cin.failbit);
int n,m;
cin>>n>>m;
for(int i=1;i<=n;i++)
{
int k;
cin>>k;
polys[i].resize(k);
for(auto&[x,y]:polys[i])
cin>>x>>y;
}
for(int i=1;i<=m;i++)
cin>>paths[i].fi[0]>>paths[i].fi[1]>>paths[i].fi[2]>>paths[i].se[0]>>paths[i].se[1]>>paths[i].se[2];
{
for(int i=1;i<=m;i++)
{
auto[p1,p2]=paths[i];
auto[x1,y1,z1]=p1;
auto[x2,y2,z2]=p2;
int a=x2-x1;
int b=y2-y1;
int val1=a*x1+b*y1;
int val2=a*x2+b*y2;
if(val1>val2)
swap(val1,val2);
auto check=[&](pii p)
{
int val=a*p.fi+b*p.se;
return val1<=val&&val<=val2;
};
for(int j=1;j<=n;j++)
{
bool cur=true;
for(auto p:polys[j])
if(!check(p))
{
cur=false;
break;
}
if(cur)
okok[j][i]=true;
}
}
for(int j=1;j<=n;j++) {
bool curokok=false;
for(int i=1;i<=m;i++)
if(okok[j][i])
curokok=true;
if (!curokok)
cout<<"impossible",exit(0);
}
}
double lo=0,hi=M_PI;
// lo=hi=48.031693036*M_PI/180;
bool pos=false;
while(clock()*1.0/CLOCKS_PER_SEC<1.9)
{
double mi=(lo+hi)/2;
for(int i=1;i<=n;i++)
ok[i]=false;
for(int i=1;i<=m;i++)
{
auto[p1,p2]=paths[i];
auto[x1,y1,z1]=p1;
auto[x2,y2,z2]=p2;
double a=y2-y1;
double b=x1-x2;
double s=sqrt((ll)a*a+(ll)b*b);
a/=s;
b/=s;
double d1=z1*tan(mi);
pair q1(x1+a*d1,y1+b*d1);
pair q2(x1-a*d1,y1-b*d1);
double d2=z2*tan(mi);
pair q3(x2-a*d2,y2-b*d2);
pair q4(x2+a*d2,y2+b*d2);
// cout<<q1.fi<<" "<<q1.se<<"\n";
// cout<<q2.fi<<" "<<q2.se<<"\n";
// cout<<q3.fi<<" "<<q3.se<<"\n";
// cout<<q4.fi<<" "<<q4.se<<"\n";
// cout<<"\n";
auto check=[&](pii p)
{
return small(q1,q4,p) == small(q1,q4, {p1[0],p1[1]}) && small(q2,q3,p) == small(q2,q3, {p1[0],p1[1]});
};
for(int j=1;j<=n;j++)
if(okok[j][i]&&!ok[j])
{
bool cur=true;
for(auto p:polys[j])
if(!check(p))
{
cur=false;
break;
}
if(cur)
ok[j]=true;
}
}
bool ans=true;
for(int j=1;j<=n;j++)
if(!ok[j])
{
ans=false;
break;
}
if(ans)
pos=true;
(ans?hi:lo)=mi;
}
// if(!pos) cout<<"fegrt"; else
cout<<fixed<<setprecision(10)<<(lo+hi)/2*180/M_PI;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 879ms
memory: 4452kb
input:
1 1 3 -5 0 5 0 0 5 -10 10 10 10 10 10
output:
45.0000000000
result:
ok
Test #2:
score: 0
Accepted
time: 904ms
memory: 4556kb
input:
1 1 3 -5 0 5 0 0 5 -10 0 10 10 0 10
output:
26.5650511771
result:
ok
Test #3:
score: 0
Accepted
time: 1212ms
memory: 4392kb
input:
1 1 3 -5 0 5 0 0 5 0 10 10 10 0 10
output:
46.6861433417
result:
ok
Test #4:
score: 0
Accepted
time: 958ms
memory: 4188kb
input:
1 1 3 -5 0 5 0 0 5 0 10 5 10 0 10
output:
59.4910411338
result:
ok
Test #5:
score: 0
Accepted
time: 908ms
memory: 4424kb
input:
1 1 3 -5 0 5 0 0 5 0 10 20 -10 0 10
output:
31.2196984474
result:
ok
Test #6:
score: 0
Accepted
time: 1137ms
memory: 4516kb
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.5288077092
result:
ok
Test #7:
score: 0
Accepted
time: 1020ms
memory: 4456kb
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: 1252ms
memory: 4444kb
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: 0ms
memory: 3764kb
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: 3688kb
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: 942ms
memory: 4376kb
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: 1113ms
memory: 4536kb
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: 1836ms
memory: 4284kb
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: 1ms
memory: 3828kb
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: 1891ms
memory: 4680kb
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: 1896ms
memory: 4520kb
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: 1892ms
memory: 4692kb
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: 1888ms
memory: 4584kb
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: 1892ms
memory: 4692kb
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