QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#591569 | #7785. Three Rectangles | solar_express# | WA | 1ms | 3940kb | C++14 | 2.3kb | 2024-09-26 16:30:42 | 2024-09-26 16:30:43 |
Judging History
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 main(){
//freopen("1.in","r",stdin);
cin>>T;
while(T--){
scanf("%d%d%d%d%d%d%d%d",&n,&m,&a,&b,&c,&d,&e,&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;
}
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-8+mod)%mod;
else if(b+d>=m)ans=(ans-4+mod)%mod;
if(b+d<m)ans=(ans+2*(f-(m-b-d)+1))%mod;
else ans=(ans+2*(m-f+1))%mod;
if(b+f<m)ans=(ans+2*(d-(m-b-f)+1))%mod;
else ans=(ans+2*(m-d+1))%mod;
if(d+f<m)ans=(ans+2*(b-(m-d-f)+1))%mod;
else ans=(ans+2*(m-b+1))%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: 3940kb
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: 3884kb
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: 3812kb
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: 3752kb
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 777777751 456790164 0 0 0 0 0 6 222222208 777777751 135802502 0 0 0 0 6 222222208 666666652 777777751 814814847 0 0 0 6 222222208 666666652 111111089 777777751 493827185 0 0 6 222222208 666666652 111111089 555555533 777777751 172839523 0 6 222222208 666666652 111111089 555555533 999999...
result:
wrong answer 8th numbers differ - expected: '777777753', found: '777777751'