QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#698372#7785. Three RectanglesQF_love_younger_sisterWA 1ms3680kbC++233.0kb2024-11-01 19:12:442024-11-01 19:12:45

Judging History

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

  • [2024-11-01 19:12:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3680kb
  • [2024-11-01 19:12:44]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=2e3+10;
const int mod=1e9+7;
struct qfmm{
	int h,w;
}q[N];
bool cmp(qfmm a,qfmm b){
	if(a.h==b.h) return a.w>b.w;
	return a.h>b.h;
}
int h,w;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t;
	cin >> t;
	while(t--){
		cin >> h >> w;
		for(int i=0;i<=2;i++){
			cin >> q[i].h >> q[i].w;
		}
		sort(q,q+3,cmp);
		int flag=0,dh=0,dl=0,da=0;
		for(int i=0;i<=2;i++){
			if(q[i].h==h && q[i].w==w) flag=1;
			if(q[i].h==h) dh++;
			if(q[i].w==w) dl++;
		}
		if(flag==1){
			da=(da+(h-q[1].h+1)%mod*(h-q[2].h+1)%mod*(w-q[1].w+1)%mod*(w-q[2].w+1)%mod)%mod;
			cout << da << "\n";
			continue;
		}
		else{
			if(dh<dl){
				swap(h,w);
				swap(dl,dh);
				for(int i=0;i<=2;i++){
					swap(q[i].h,q[i].w);
				}
			}
			sort(q,q+3,cmp);
			if(dh==0 && dl==0){
				cout << 0 << "\n";
				continue;
			}
			if(dh==1 && dl==0){
				if(q[1].w>=w-q[0].w && q[2].w>=w-q[0].w && q[1].h+q[2].h>=h){
					da+=4;
					cout << da << "\n";
					continue;
				}
				else{
					cout << 0 << "\n";
					continue;
				}
			}
			if(dh==2 && (dl==0 || dl==1)){
				//本身不覆盖
				if(q[0].w+q[1].w<w){
					cout << 0 << "\n";
					continue;
				}
				//本身覆盖
				else{
					cout << 2*(h-q[2].h+1)%mod*(w-q[2].w+1)%mod << "\n";
					continue;
				}
			}
			if(dh==3 && dl==0){
				int yubj=0;
				for(int i=0;i<=2;i++){
					for(int j=0;j<=2;j++){
						for(int k=0;k<=2;k++){
							if(i!=j && i!=k && j!=k){
								if(q[i].w+q[j].w>=w){
									da+=w-q[k].w+1;
									yubj+=2;
								}
								else{
									int kuan=w-q[i].w-q[j].w;
									if(q[k].w-kuan>0){
//										if(q[k].w-kuan>=q[i].w){
//											yubj++;
//										}
//										if(q[k].w-kuan>=q[j].w){
//											yubj++;
//										}
//										da+=min(q[k].w-kuan,w-q[i].w)+min(q[k].w-kuan,w-q[j].w);
										int flag1=0,flag2=0;
										if(q[k].w>=w-q[j].w) flag1=1;
										if(q[k].w>=w-q[i].w) flag2=1;
										if(flag1&&flag2){
											da+=w-q[k].w+1;
											yubj+=2;
										}
										if(!flag1 && flag2){
											da+=q[j].w+1;
											yubj++;
										}
										if(flag1 && !flag2){
											da+=q[i].w+1;
											yubj++;
										}
										if(!flag1 && !flag2){
											da+=(q[k].w-kuan)*2;
										}
									}
									else{
										if(q[k].w-kuan==0){
											da+=1;
										}
									}
								}
//								cout << i << " " << j << " " << k << "\n";
//								cout << da << " " << yubj << "\n";
//								cout << "\n";
							}
						}
					}
				}
			//	cout << da << "\n";
			//	cout << yubj << "\n";
				cout << (da-yubj/2)%mod << "\n";
				continue;
			}
			if(dh==1 && dl==1){
				if(q[2].w==w){
					swap(q[1].w,q[2].w);
					swap(q[1].h,q[2].h);
				}
				if(q[2].h>=h-q[1].h && q[2].w >= w-q[0].w){
					cout << 4 << "\n";
				}
				else cout << 0 << "\n";
				continue;
			}
		}
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 3620kb

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: 3612kb

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: 3672kb

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: 3680kb

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 96th numbers differ - expected: '666666672', found: '333333325'