QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#591632#7785. Three Rectanglessolar_express#WA 1ms3896kbC++142.4kb2024-09-26 16:56:292024-09-26 16:56:29

Judging History

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

  • [2024-09-26 16:56:29]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3896kb
  • [2024-09-26 16:56:29]
  • 提交

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 sol(int x,int y,int z){
	if(x+y>=m)return (m-z+1);
	int l=max(1,m-y-z+1),r=min(m,x+z);
	return (r-l+1-z+1)%mod;
}
int main(){
	//freopen("1.in","r",stdin);
	cin>>T;
	int jsqq=0;
	while(T--){
		jsqq++;
		scanf("%d%d%d%d%d%d%d%d",&n,&m,&a,&b,&c,&d,&e,&f);
		if(jsqq==314){
			cout<<n<<" "<<m<<" "<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<d<<" "<<f<<endl;
			return 0;
		}
		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(d>b)swap(b,d);if(f>b)swap(b,f);if(f>d)swap(d,f);
				if(d+f>=m)ans=(ans-6+mod)%mod;
				else if(b+f>=m)ans=(ans-6+mod)%mod;
				else if(b+d>=m)ans=(ans-4+mod)%mod;
				ans=(ans+2*sol(b,d,f))%mod;
				ans=(ans+2*sol(b,f,d))%mod;
				ans=(ans+2*sol(d,f,b))%mod;
				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: 100
Accepted
time: 0ms
memory: 3896kb

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
6
4

result:

ok 5 number(s): "0 8 4 6 4"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3852kb

input:

4
1 3
1 1
1 2
1 3
1 4
1 1
1 2
1 3
1 5
1 1
1 2
1 3
1 6
1 1
1 2
1 3

output:

6
12
14
6

result:

ok 4 number(s): "6 12 14 6"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3876kb

input:

1
1000000000 1000000000
1 1
1 1
1000000000 1000000000

output:

2401

result:

ok 1 number(s): "2401"

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 3788kb

input:

729
999999999 111111111
111111111 111111111
111111111 111111111
111111111 111111111
999999999 111111111
111111111 111111111
222222222 111111111
111111111 111111111
999999999 111111111
111111111 111111111
111111111 111111111
333333333 111111111
999999999 111111111
111111111 111111111
444444444 111111...

output:

0
0
0
0
0
0
6
777777753
456790164
0
0
0
0
0
6
222222208
555555531
135802502
0
0
0
0
6
222222208
222222208
333333309
814814847
0
0
0
6
222222208
222222208
222222208
111111087
493827185
0
0
6
222222208
222222208
222222208
222222208
888888872
172839523
0
6
222222208
222222208
222222208
222222208
222222...

result:

wrong answer 314th numbers differ - expected: '555555547', found: '999999999'