QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#364914 | #5067. Two Walls | ISYRHH | WA | 88ms | 1572kb | C++14 | 3.1kb | 2024-03-24 17:19:10 | 2024-03-24 17:19:12 |
Judging History
answer
#include<cstdio>
#include<vector>
using namespace std;
int n;
inline int gt(int x,int y,int xx,int yy)
{
long long r=1ll*x*yy-1ll*y*xx;
if(r>0)return 1;
else if(r<0)return -1;
else return 0;
}
inline bool hhx(int x,int y,int xx,int yy)
{
if(x>y)swap(x,y);
if(xx>yy)swap(xx,yy);
return max(x,xx)<=min(y,yy);
}
inline bool ggx(int x,int y,int xx,int yy)
{
if(x>y)swap(x,y);
if(xx>yy)swap(xx,yy);
return max(x,xx)<min(y,yy);
}
inline bool hx(int x,int y,int xx,int yy,int a,int b,int c,int d)
{
if(gt(xx-x,yy-y,c-a,d-b)==0)
{
if(hhx(x,xx,a,c)&&hhx(y,yy,b,d))return true;
else return false;
}
else
{
return gt(xx-x,yy-y,a-x,b-y)*gt(xx-x,yy-y,c-x,d-y)<=0&>(c-a,d-b,x-a,y-b)*gt(c-a,d-b,xx-a,yy-b)<=0;
}
}
inline bool gx(int x,int y,int xx,int yy,int a,int b,int c,int d)
{
if(gt(xx-x,yy-y,c-a,d-b)==0)
{
if(ggx(x,xx,a,c)&&ggx(y,yy,b,d))return true;
else return false;
}
else
{
return gt(xx-x,yy-y,a-x,b-y)*gt(xx-x,yy-y,c-x,d-y)<0&>(c-a,d-b,x-a,y-b)*gt(c-a,d-b,xx-a,yy-b)<0;
}
}
int main()
{
scanf("%d",&n);
for(int i=1;i<=n;i++)
{
int x,y,xx,yy;
scanf("%d%d%d%d",&x,&y,&xx,&yy);
int wk=0;
int a,b,c,d;
scanf("%d%d%d%d",&a,&b,&c,&d);
if(hx(x,y,xx,yy,a,b,c,d))wk++;
int e,f,g,h;
scanf("%d%d%d%d",&e,&f,&g,&h);
if(hx(x,y,xx,yy,e,f,g,h))wk++;
if(wk==2)
{
bool bb=true,b1=gx(x,y,a,b,e,f,g,h),b2=gx(x,y,c,d,e,f,g,h),b3=gx(xx,yy,a,b,e,f,g,h),b4=gx(xx,yy,c,d,e,f,g,h),b5=gx(x,y,e,f,a,b,c,d),b6=gx(x,y,g,h,a,b,c,d),b7=gx(xx,yy,e,f,a,b,c,d),b8=gx(xx,yy,g,h,a,b,c,d);
if(!gx(a,b,c,d,e,f,g,h))
{
printf("1");
}
else if(!b1&&!b7&>(x-a,y-b,e-xx,f-yy)*gt(x-a,y-b,xx-x,yy-y)<0)
{
printf("1\n");
}
else if(!b1&&!b8&>(x-a,y-b,g-xx,h-yy)*gt(x-a,y-b,xx-x,yy-y)<0)
{
printf("1\n");
}
else if(!b2&&!b7&>(x-c,y-d,e-xx,f-yy)*gt(x-c,y-d,xx-x,yy-y)<0)
{
printf("1\n");
}
else if(!b2&&!b8&>(x-c,y-d,g-xx,h-yy)*gt(x-c,y-d,xx-x,yy-y)<0)
{
printf("1\n");
}
else if(!b3&&!b5&>(xx-a,yy-b,e-x,f-y)*gt(xx-a,yy-b,x-xx,y-yy)<0)
{
printf("1\n");
}
else if(!b3&&!b6&>(xx-a,yy-b,g-x,h-y)*gt(xx-a,yy-b,x-xx,y-yy)<0)
{
printf("1\n");
}
else if(!b4&&!b5&>(xx-c,yy-d,e-x,f-y)*gt(xx-c,yy-d,x-xx,y-yy)<0)
{
printf("1\n");
}
else if(!b4&&!b6&>(xx-c,yy-d,g-x,h-y)*gt(xx-c,yy-d,x-xx,y-yy)<0)
{
printf("1\n");
}
else if(!b1&&!b3)
{
printf("1\n");
}
else if(!b2&&!b4)
{
printf("1\n");
}
else if(!b7&&!b5)
{
printf("1\n");
}
else if(!b8&&!b6)
{
printf("1\n");
}
else if(gt(xx-x,yy-y,a-x,b-y)*gt(xx-x,yy-y,c-x,d-y)>=0&>(xx-x,yy-y,a-x,b-y)*gt(xx-x,yy-y,e-x,f-y)>=0&>(xx-x,yy-y,a-x,b-y)*gt(xx-x,yy-y,g-x,h-y)>=0&>(xx-x,yy-y,c-x,d-y)*gt(xx-x,yy-y,g-x,h-y)>=0&>(xx-x,yy-y,c-x,d-y)*gt(xx-x,yy-y,e-x,f-y)>=0&>(xx-x,yy-y,g-x,h-y)*gt(xx-x,yy-y,e-x,f-y)>=0)
{
printf("1\n");
}
else
{
printf("2\n");
}
}
else if(wk==1)
{
printf("1\n");
}
else
{
printf("0\n");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1536kb
input:
3 0 0 1 1 2 2 3 3 4 4 5 5 0 0 1 1 2 2 3 3 2 2 3 3 0 0 10 10 10 0 0 10 1 1 2 2
output:
0 0 1
result:
ok 3 number(s): "0 0 1"
Test #2:
score: 0
Accepted
time: 0ms
memory: 1572kb
input:
2 -999999999 999999998 999999999 999999998 -1000000000 -1000000000 1000000000 1000000000 1000000000 -1000000000 -1000000000 1000000000 -999999999 999999998 999999999 999999998 -999999998 -999999998 1000000000 1000000000 999999998 -999999998 -1000000000 1000000000
output:
2 1
result:
ok 2 number(s): "2 1"
Test #3:
score: 0
Accepted
time: 0ms
memory: 1520kb
input:
1 0 0 1 1 2 2 3 3 4 4 5 5
output:
0
result:
ok 1 number(s): "0"
Test #4:
score: -100
Wrong Answer
time: 88ms
memory: 1568kb
input:
100000 -851839419 34688642 -667081997 395784949 -624068418 -155389155 119194510 -758711821 -992436155 -812775173 851861070 -592596572 974613003 -179673992 -485749861 520596304 -115838823 -265233646 -573799007 -222234500 608830643 -887109945 483106217 -906910755 -597593284 384264657 940783 476657007 ...
output:
0 0 0 0 0 0 10 0 0 0 1 0 0 1 1 0 0 1 1 1 0 1 0 0 1 0 1 0 0 0 0 0 1 0 0 1 0 1 0 0 0 0 0 1 1 1 1 1 0 1 1 0 0 0 0 1 1 0 1 0 0 0 0 0 0 0 0 1 1 0 1 0 0 1 0 0 0 0 1 1 1 1 1 1 0 0 0 11 1 0 0 0 0 1 0 0 0 0 0 0 0 10 0 0 0 0 0 0 0 1 11 0 1 1 0 0 0 0 0 0 1 0 1 1 0 1 0 0 1 0 0 1 1 0 0 0 10 1 0 1 0 0 0 1 1 0 0 0...
result:
wrong answer 7th numbers differ - expected: '1', found: '10'