QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#769421#7785. Three Rectanglesi0streamWA 0ms3892kbC++141.9kb2024-11-21 17:30:562024-11-21 17:31:03

Judging History

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

  • [2024-11-21 17:31:03]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3892kb
  • [2024-11-21 17:30:56]
  • 提交

answer

#include <bits/stdc++.h>
#define h1 r[1].h
#define h2 r[2].h
#define h3 r[3].h
#define w1 r[1].w
#define w2 r[2].w
#define w3 r[3].w

using namespace std;
typedef long long ll;
const ll P=1e9+7;

ll H,W,spc,ans,cnth,cntw;

struct node{ll h,w;}r[5];

inline bool cmp(node x,node y){
	if (x.h==H) return 1;
	else if (y.h==H) return 0;
	else if (x.w==W) return 1;
	else if (y.w==W) return 0;
	else return 1;
}

inline ll fr(int id){
	return 1ll*(H-r[id].h+1)*(W-r[id].w+1)%P;
}

inline ll Min(ll a,ll b){return a<b?a:b;}
inline ll Max(ll a,ll b){return a>b?a:b;}

int main(){
	scanf("%lld%lld",&H,&W);
	for (int i=1;i<=3;i++){
		scanf("%lld%lld",&r[i].h,&r[i].w);
		if (r[i].h==H && r[i].w==W) spc=1;
		if (r[i].h==H) cnth++;
		if (r[i].w==W) cntw++;
	}
	if (spc){
		printf("%lld\n",fr(1)*fr(2)%P*fr(3)%P);
		return 0;
	}
	if (cnth==3 && cntw==0 || cnth==1 && cntw==0 || cnth==2 && cntw==1 || cnth==2 && cntw==0){
		swap(r[1].h,r[1].w);
		swap(r[2].h,r[2].w);
		swap(r[3].h,r[3].w);
		swap(cnth,cntw);
	}
	sort(r+1,r+4,cmp);
	if (cnth==0 && cntw==0) ans=0;
	else if (cnth==0 && cntw==1){
		if (h1+h2>=H && h1+h3>=H && w2+w3>=W) ans=4;
	}else if (cnth==0 && cntw==2){
		if (h1+h2>=H) ans=2*fr(3)%P;
	}else if (cnth==0 && cntw==3){
		if (h1+h2+h3>=H){
			int nh1=h1,nh2=h2,nh3=h3;
			ans=(ans+Min(nh1+nh2,H)-Max(H-nh3,nh2)+1)%P;
			nh1=h1,nh2=h3,nh3=h2;
			ans=(ans+Min(nh1+nh2,H)-Max(H-nh3,nh2)+1)%P;
			nh1=h2,nh2=h1,nh3=h3;
			ans=(ans+Min(nh1+nh2,H)-Max(H-nh3,nh2)+1)%P;
			nh1=h2,nh2=h3,nh3=h1;
			ans=(ans+Min(nh1+nh2,H)-Max(H-nh3,nh2)+1)%P;
			nh1=h3,nh2=h1,nh3=h2;
			ans=(ans+Min(nh1+nh2,H)-Max(H-nh3,nh2)+1)%P;
			nh1=h3,nh2=h2,nh3=h1;
			ans=(ans+Min(nh1+nh2,H)-Max(H-nh3,nh2)+1)%P;
		}else ans=0;
	}else if (cnth==1 && cntw==1){
		if (h2+h3>=H && w1+w3>=W) ans=4;
	}else if (cnth==1 && cntw==2){
		if (h2+h3>=H) ans=2*fr(1)%P;
	}
	printf("%lld\n",ans);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

result:

wrong answer Answer contains longer sequence [length = 5], but output contains 1 elements