QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#621625 | #7785. Three Rectangles | Green_Hand | WA | 0ms | 1592kb | C++20 | 2.0kb | 2024-10-08 15:45:30 | 2024-10-08 15:45:32 |
Judging History
answer
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long ll;
const int P = 1E9 + 7;
int T,n,m,ans,x[9],y[9]; ll mx;
void read(int &x)
{
char c = getchar(); x = 0;
while(c < '0' || c > '9') c = getchar();
while(c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
}
int count(int x,int y) { return max(0,y - x + 1); }
int main()
{
for(read(T);T--;)
{
read(n), read(m), mx = 0ll;
for(int i = 0;i < 3; ++ i)
read(x[i]), read(y[i]), mx = max(mx,1ll * x[i] * y[i]);
if(mx == 1ll * n * m)
{
ans = 1;
for(int i = 0;i < 3; ++ i)
ans = 1ll * ans * (n - x[i] + 1) % P * (m - y[i] + 1) % P;
printf("%d\n",ans);
continue;
}
int tmp1 = (x[0] == n) + (x[1] == n) + (x[2] == n);
int tmp2 = (y[0] == m) + (y[1] == m) + (y[2] == m);
if(tmp1 < tmp2) swap(n,m), swap(x[0],y[0]), swap(x[1],y[1]), swap(x[2],y[2]), swap(tmp1,tmp2);
if(!tmp1) printf("0\n");
else if(tmp1 == 3)
{
ans = 0ll;
if(y[0] + y[1] + y[2] < m) { printf("0\n"); continue; }
for(int i = 0;i < 3; ++ i)
for(int j = 0,l,r;j < 3; ++ j) if(i != j)
{
l = y[i], r = m - y[j];
if(y[i] + y[j] >= m) ans = (ans + m - y[3 - i - j] + 1) % P;
else ans = (ans + count(max(r - y[3 - i - j],0),min(m - y[3 - i - j],l))) % P;
}
for(int i = 0;i < 3; ++ i)
for(int j = 0;j < 3; ++ j)
if(i != j && max(y[i],y[j]) + y[3 - i - j] >= m) --ans;
printf("%d\n",(ans + P) % P);
continue;
}
else if(tmp1 == 2)
{
if(x[1] < n) swap(x[0],x[1]), swap(y[0],y[1]);
if(x[2] < n) swap(x[0],x[2]), swap(y[0],y[2]);
if(y[1] + y[2] < m) printf("0\n");
else printf("%lld\n",2ll * (n - x[0] + 1) % P * (m - y[0] + 1) % P);
}
else if(tmp1 == 1)
{
if(x[1] == n) swap(x[0],x[1]), swap(y[0],y[1]);
if(x[2] == n) swap(x[0],x[2]), swap(y[0],y[2]);
if(x[1] + x[2] >= n && min(y[1],y[2]) + y[0] >= m) printf("4\n");
else printf("0\n");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 1512kb
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: 1516kb
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: 1520kb
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: 0ms
memory: 1592kb
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'