QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#591479#7785. Three Rectanglessolar_express#WA 0ms3948kbC++142.0kb2024-09-26 16:06:062024-09-26 16:06:07

Judging History

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

  • [2024-09-26 16:06:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3948kb
  • [2024-09-26 16:06:06]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
int T;
int n,m,a,b,c,d,e,f;
long long ans;
int main(){
	cin>>T;
	while(T--){
		scanf("%d%d%d%d%d%d%d%d",&n,&m,&a,&b,&c,&d,&e,&f);
		if(a==n&&b==m){
			ans=1ll*(n-c+1)*(m-d+1)%mod*(n-e+1)%mod*(m-f+1)%mod;
			printf("%lld\n",ans);continue;
		}
		swap(a,c);swap(b,d);
		if(a==n&&b==m){
			ans=1ll*(n-c+1)*(m-d+1)%mod*(n-e+1)%mod*(m-f+1)%mod;
			printf("%lld\n",ans);continue;
		}
		swap(a,e);swap(b,f);
		if(a==n&&b==m){
			ans=1ll*(n-c+1)*(m-d+1)%mod*(n-e+1)%mod*(m-f+1)%mod;
			printf("%lld\n",ans);continue;
		}
		int jsq=(a==n)+(b==m)+(c==n)+(d==m)+(e==n)+(f==m);
		if(!jsq){puts("0");continue;}
		else if(jsq==1){
			if((c==n)||(d==m)){swap(a,c);swap(b,d);}
			if((e==n)||(f==m)){swap(a,e);swap(b,f);}
			if(b==m){swap(a,b);swap(c,d);swap(e,f);swap(n,m);}
			if(d<m-b||f<m-b){puts("0");continue;}
			if(c+e<n){puts("0");continue;}
			puts("4");
			continue;
		}
		else if(jsq==2){
			if((c==n)||(d==m)){swap(a,c);swap(b,d);}
			if((e==n)||(f==m)){swap(a,e);swap(b,f);}
			if((e==n)||(f==m)){swap(c,e);swap(d,f);}
			if(b==m){swap(a,b);swap(c,d);swap(e,f);swap(n,m);}
			if(c==n){
				if(b+d<m){puts("0");continue;}
				ans=2ll*(n-e+1)*(m-f+1)%mod;
				printf("%lld\n",ans);continue;
			}
			else{
				if(d<m-b||f<m-b){puts("0");continue;}
				if(c+e<n){puts("0");continue;}
				puts("4");
				continue;
			}
		}
		else if(jsq==3){
			if(b==m){swap(a,b);swap(c,d);swap(e,f);swap(n,m);}
			if(a==n&&c==n&&e==n){
				if(b+d+f<m){puts("0");continue;}
				ans=0;
				if(b+d>=m)ans+=2*(m-f-1);
				else ans+=2*(f-(m-b-d)+1);
				if(b+f>=m)ans+=2*(m-d-1);
				else ans+=2*(d-(m-b-f)+1);
				if(d+f>=m)ans+=2*(m-b-1);
				else ans+=2*(b-(m-d-f)+1);
				printf("%lld\n",ans);continue;
			}
			else{
				if(c!=n&&e!=n){swap(a,b);swap(c,d);swap(e,f);swap(n,m);swap(a,e);swap(b,f);}
				else if(c!=n){swap(c,e);swap(d,f);}
				if(b+d<m){puts("0");continue;}
				ans=2ll*(n-e+1)*(m-f+1)%mod;
				printf("%lld\n",ans);continue;
			}
		}
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3948kb

input:

5
2 2
1 1
1 1
1 1
2 2
1 1
1 2
1 2
2 2
1 1
1 2
2 1
2 2
1 2
1 2
1 2
2 2
1 2
1 2
2 1

output:

0
8
4
0
4

result:

wrong answer 4th numbers differ - expected: '6', found: '0'