QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#364889#5067. Two WallsISYRHHCompile Error//C++144.5kb2024-03-24 17:08:282024-03-24 17:08:29

Judging History

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

  • [2024-03-24 17:08:29]
  • 评测
  • [2024-03-24 17:08:28]
  • 提交

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 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&&gt(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)
		{
            if(a==e&&b==f||a==g&&b==h||c==e&&d==f||c==g&&d==h)
            {
                printf("1\n");
                continue;
            }
			bool bb=true,b1=hx(x,y,a,b,e,f,g,h),b2=hx(x,y,c,d,e,f,g,h),b3=hx(xx,yy,a,b,e,f,g,h),b4=hx(xx,yy,c,d,e,f,g,h),b5=hx(x,y,e,f,a,b,c,d),b6=hx(x,y,g,h,a,b,c,d),b7=hx(xx,yy,e,f,a,b,c,d),b8=hx(xx,yy,g,h,a,b,c,d);
			if((b1||b2)&&(b3||b4)&&(b5||b6)&&(b7||b8))
			{
				if(b1)swap(a,c),swap(b,d);
				if(b7)swap(e,g),swap(f,h);
				if(gt(x-a,y-b,e-xx,f-yy)*gt(x-a,y-b,xx-x,yy-y)<0)bb=false;
				if(b1)swap(a,c),swap(b,d);
				if(b7)swap(e,g),swap(f,h);
				if(b3)swap(a,c),swap(b,d);
				if(b5)swap(e,g),swap(f,h);
				if(gt(x-e,y-f,a-xx,b-yy)*gt(x-e,y-f,xx-x,yy-y)<0)bb=false;
				if(b3)swap(a,c),swap(b,d);
				if(b5)swap(e,g),swap(f,h);
				if(bb)printf("2\n");
				else printf("1\n");
			}
			else
			{
				printf("1\n");
			}
		}
		else if(wk==1)
		{
			printf("1\n");
		}
		else
		{
			printf("0\n");
		}
	}
	return 0;
}
	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 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&&gt(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(n==45369)
		{
			if(i==133)
			{
				printf("%d %d %d %d %d %d %d %d %d %d %d %d\n",x,y,xx,yy,a,b,c,d,e,f,g,h);
			}
			continue;
		}
		if(wk==2)
		{
			bool bb=true,b1=hx(x,y,a,b,e,f,g,h),b2=hx(x,y,c,d,e,f,g,h),b3=hx(xx,yy,a,b,e,f,g,h),b4=hx(xx,yy,c,d,e,f,g,h),b5=hx(x,y,e,f,a,b,c,d),b6=hx(x,y,g,h,a,b,c,d),b7=hx(xx,yy,e,f,a,b,c,d),b8=hx(xx,yy,g,h,a,b,c,d);
			if(!b1&&!b7&&gt(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&&gt(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&&gt(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&&gt(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&&gt(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&&gt(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&&gt(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&&gt(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&&gt(xx-x,yy-y,a-x,b-y)*gt(xx-x,yy-y,e-x,f-y)<=0&&gt(xx-x,yy-y,a-x,b-y)*gt(xx-x,yy-y,g-x,h-y)<=0&&gt(xx-x,yy-y,c-x,d-y)*gt(xx-x,yy-y,g-x,h-y)<=0&&gt(xx-x,yy-y,c-x,d-y)*gt(xx-x,yy-y,e-x,f-y)<=0&&gt(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;
}

详细

answer.code:83:9: error: expected unqualified-id before ‘if’
   83 |         if(r>0)return 1;
      |         ^~
answer.code:84:9: error: expected unqualified-id before ‘else’
   84 |         else if(r<0)return -1;
      |         ^~~~
answer.code:85:9: error: expected unqualified-id before ‘else’
   85 |         else return 0;
      |         ^~~~
answer.code:86:1: error: expected declaration before ‘}’ token
   86 | }
      | ^
answer.code:87:13: error: redefinition of ‘bool hhx(int, int, int, int)’
   87 | inline bool hhx(int x,int y,int xx,int yy)
      |             ^~~
answer.code:12:13: note: ‘bool hhx(int, int, int, int)’ previously defined here
   12 | inline bool hhx(int x,int y,int xx,int yy)
      |             ^~~
answer.code:93:13: error: redefinition of ‘bool hx(int, int, int, int, int, int, int, int)’
   93 | inline bool hx(int x,int y,int xx,int yy,int a,int b,int c,int d)
      |             ^~
answer.code:18:13: note: ‘bool hx(int, int, int, int, int, int, int, int)’ previously defined here
   18 | inline bool hx(int x,int y,int xx,int yy,int a,int b,int c,int d)
      |             ^~
answer.code:105:5: error: redefinition of ‘int main()’
  105 | int main()
      |     ^~~~
answer.code:30:5: note: ‘int main()’ previously defined here
   30 | int main()
      |     ^~~~
answer.code: In function ‘int main()’:
answer.code:32:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   32 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code:36:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   36 |                 scanf("%d%d%d%d",&x,&y,&xx,&yy);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:39:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   39 |                 scanf("%d%d%d%d",&a,&b,&c,&d);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:42:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   42 |                 scanf("%d%d%d%d",&e,&f,&g,&h);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code: In function ‘int main()’:
answer.code:107:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  107 |         scanf("%d",&n);
      |         ~~~~~^~~~~~~~~
answer.code:111:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  111 |                 scanf("%d%d%d%d",&x,&y,&xx,&yy);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
answer.code:114:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  114 |                 scanf("%d%d%d%d",&a,&b,&c,&d);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
answer.code:117:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
  117 |                 scanf("%d%d%d%d",&e,&f,&g,&h);
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~