QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#346324#7785. Three Rectangles275307894a#WA 1ms4024kbC++142.6kb2024-03-08 11:25:172024-03-08 11:25:17

Judging History

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

  • [2024-03-08 11:25:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:4024kb
  • [2024-03-08 11:25:17]
  • 提交

answer

#include<bits/stdc++.h>
#define Gc() getchar()
#define Me(x,y) memset(x,y,sizeof(x))
#define Mc(x,y) memcpy(x,y,sizeof(x))
#define d(x,y) ((m)*(x-1)+(y))
#define R(n) (rnd()%(n)+1)
#define Pc(x) putchar(x)
#define LB lower_bound
#define UB upper_bound
#define fi first
#define se second
#define eb emplace_back
#define all(x) x.begin(),x.end()
using namespace std;using ll=long long;using db=double;using lb=long db;using ui=unsigned;using ull=unsigned long long;using pii=pair<int,int>;
const int N=50+5,M=N*50+5,K=1000+5,mod=1e9+7,Mod=mod-1;const db eps=1e-9;const ll INF=2e18+7;mt19937 rnd(263082);
#define Tp template<typename T>
#define Ts template<typename T,typename... Ar>
namespace Debug{
	Tp void _debug(char* f,T t){cerr<<f<<'='<<t<<endl;}
	Ts void _debug(char* f,T x,Ar... y){while(*f!=',') cerr<<*f++;cerr<<'='<<x<<",";_debug(f+1,y...);}
	#ifdef LOCAL
	#define gdb(...) _debug((char*)#__VA_ARGS__,__VA_ARGS__)
	#else 
	#define gdb(...) void()
	#endif
}using namespace Debug;
ll H,W;
pair<ll,ll> A[3];
ll qry(int a,int b,int c,int k){
	if(a+b>=k) return 2*(k-c+1);
	return 2*(min(a+1,k-c+1)-max(1,k-b+1-c)+1);
}
ll calc(int a,int b,int c,int k){
	if(a+b+c<k) return 0;
	if(a>b) swap(a,b);if(a>c) swap(a,c);if(b>c) swap(b,c);
	ll ans=qry(a,b,c,k)+qry(a,c,b,k)+qry(b,c,a,k);
	// gdb(qry(1,2,3,4));
	// gdb(ans);
	if(b+c>=k) ans-=4;
	if(a+c>=k) ans-=2;
	return ans%mod;
}
bool cmp(pii x,pii y){return make_pair(x.se,x.fi)<make_pair(y.se,y.fi);}
void Solve(){
	int i,j;scanf("%lld%lld",&H,&W);
	for(i=0;i<3;i++) scanf("%lld%lld",&A[i].fi,&A[i].se);
	sort(A,A+3);
	if(A[2].fi==H&&A[2].se==W){
		ll ans=1;
		for(int i=0;i<2;i++) ans=ans*(H-A[i].fi+1)%mod*(W-A[i].se+1)%mod;
		printf("%lld\n",ans);
		return;
	}
	if(A[0].fi==H){
		printf("%lld\n",calc(A[0].se,A[1].se,A[2].se,W));
		return;
	}
	sort(A,A+3,cmp);
	if(A[0].se==W){
		printf("%lld\n",calc(A[0].fi,A[1].fi,A[2].fi,H));
		return;
	}
	sort(A,A+3);
	if(A[1].fi==H&&A[2].fi==H&&A[1].se+A[2].se>=W){
		printf("%lld\n",2ll*(H-A[0].fi+1)*(W-A[0].se+1)%mod);
		return;
	}
	sort(A,A+3,cmp);
	if(A[1].se==H&&A[2].se==H&&A[1].fi+A[2].fi>=H){
		printf("%lld\n",2ll*(H-A[0].fi+1)*(W-A[0].se+1)%mod);
		return;
	}
	if(A[2].se==W){
		swap(W,H);
		for(i=0;i<3;i++) swap(A[i].fi,A[i].se);
	}
	sort(A,A+3);
	if(A[2].fi^H){puts("0");return;}
	ll ans=0;
	W-=A[2].se;
	for(i=0;i<2;i++) if(W>A[i].se) {puts("0");return;}
	if(A[0].fi+A[1].fi<H){puts("0");return;}
	printf("4\n");
}
int main(){
	int t=1;
	scanf("%d",&t);
	while(t--) Solve();
	cerr<<clock()*1.0/CLOCKS_PER_SEC<<'\n';
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3972kb

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

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

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

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: '0'