QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#290913 | #7785. Three Rectangles | ucup-team134# | WA | 1ms | 3844kb | C++14 | 2.7kb | 2023-12-25 20:21:57 | 2023-12-25 20:21:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
const int mod=1e9+7;
int add(int x,int y){x+=y;return x>=mod?x-mod:x;}
int sub(int x,int y){x-=y;return x<0?x+mod:x;}
int mul(int x,int y){return (ll)x*y%mod;}
int a[3],b[3];
int main(){
int t;
scanf("%i",&t);
while(t--){
int H,W;
scanf("%i %i",&H,&W);
bool cover=false;
for(int i=0;i<3;i++){
scanf("%i %i",&a[i],&b[i]);
if(a[i]==H && b[i]==W)cover=true;
}
if(cover){
int ans=1;
for(int i=0;i<3;i++){
ans=mul(ans,mul(H-a[i]+1,W-b[i]+1));
}
printf("%i\n",ans);
}else{
int hasH=0,hasW=0;
for(int i=0;i<3;i++){
if(a[i]==H)hasH++;
if(b[i]==W)hasW++;
}
if(!hasH && !hasW)printf("0\n");
else{
if(hasW>hasH){
swap(hasH,hasW);
swap(H,W);
for(int i=0;i<3;i++){
swap(a[i],b[i]);
}
}
if(hasH==1){
int j=0;
for(int i=0;i<3;i++){
if(a[i]==H)j=i;
}
swap(a[j],a[0]);
swap(b[j],b[0]);
if(a[1]+a[2]>=H && b[1]>=W-b[0] && b[2]>=W-b[0]){
printf("4\n");
}else{
printf("0\n");
}
}else if(hasH==2){
int j=0;
for(int i=0;i<3;i++){
if(a[i]==H)j=i;
}
swap(a[j],a[0]);
swap(b[j],b[0]);
j=1;
for(int i=1;i<3;i++){
if(a[i]==H)j=i;
}
swap(a[j],a[1]);
swap(b[j],b[1]);
if(b[0]+b[1]>=W){
printf("%i\n",mul(2,mul(H-a[2]+1,W-b[2]+1)));
}else{
printf("0\n");
}
}else if(hasH==3){
if(b[0]+b[1]+b[2]<W){
printf("0\n");
}else{
int ans=0;
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
int L=0;
if(i==0)L=max(L,b[0]);
if(j==0)L=max(L,b[1]);
if(k==0)L=max(L,b[2]);
int R=0;
if(i==2)R=max(R,b[0]);
if(j==2)R=max(R,b[1]);
if(k==2)R=max(R,b[2]);
if(L==0 || R==0)continue;
int x=-1;
if(i==1){
x=b[0];
}else if(j==1){
x=b[1];
}else if(k==1){
x=b[2];
}
if(L+R>=W){
if(x!=-1){
int l=2;
int r=W-x;
if(l<=r)ans=add(ans,r-l+1);
//printf("x:%i -> l:%i r:%i\n",x,l,r);
}else{
ans=add(ans,1);
}
}else{
int gap=W-L-R;
if(x!=-1){
int l=max(2,L+gap-x+1);
int r=min(W-x,W-R-gap+1);
if(l<=r)ans=add(ans,r-l+1);
}
}
//printf("ans: %i i:%i j:%i k:%i\n",ans,i,j,k);
}
}
}
printf("%i\n",ans);
}
}
}
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3768kb
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: 3772kb
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: 3844kb
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: 3816kb
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'