QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#404060 | #7785. Three Rectangles | ucup-team3282# | WA | 2ms | 3560kb | C++14 | 1.8kb | 2024-05-03 10:40:54 | 2024-05-03 10:40:56 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
int T;
int H,W;
int h[4],w[4];
int main(){
ios::sync_with_stdio(0);
cin>>T;
while(T--){
cin>>H>>W;
for(int i=1;i<=3;i++)
cin>>h[i]>>w[i];
int x=0;
for(int i=1;i<=3;i++)
if(h[i]==H||w[i]==W)
x=i;
for(int i=1;i<=3;i++)
if(h[i]==H&&w[i]==W)
x=i;
if(x==0){
cout<<0<<endl;
continue;
}
if(w[x]==W){
swap(H,W);
for(int i=1;i<=3;i++)
swap(h[i],w[i]);
}
if(w[x]==W){
ll res=1;
for(int i=1;i<=3;i++)
if(i!=x)
res=res*(W-w[i]+1)%mod*(H-h[i]+1)%mod;
cout<<res<<endl;
continue;
}
int y=0;
for(int i=1;i<=3;i++)
if(i!=x&&h[i]==H)
y=i;
if(y==0){
int ht=0;
for(int i=1;i<=3;i++)
if(i!=x)
ht+=h[i];
if(ht<H){
cout<<0<<endl;
continue;
}
for(int i=1;i<=3;i++)
if(i!=x)
if(w[i]+w[x]<W){
cout<<0<<endl;
continue;
}
cout<<4<<endl;
continue;
}
int z=0;
for(int i=1;i<=3;i++)
if(i!=x&&i!=y)
z=i;
if(h[z]==H){
if((ll)w[x]+w[y]+w[z]<W){
cout<<0<<endl;
continue;
}
ll res=0;
for(int i=1;i<=3;i++)
for(int j=1;j<=3;j++){
if(j==i)
continue;
for(int k=1;k<=3;k++){
if(k==i||k==j)
continue;
if(w[i]+w[j]>=W)
res+=W-w[k]+1;
else
res+=min(min(w[i]+1,W-w[j]),W-w[k]+1)-max(max(w[i]-w[k]+2,W-w[j]-w[k]+1),1)+1;
// cout<<i<<' '<<j<<' '<<k<<" res "<<res<<endl;
if(k>i&&w[k]+w[j]>=W)
res--;
if(k>j&&w[k]+w[i]>=W)
res--;
}
}
res%=mod;
cout<<res<<endl;
continue;
}
if(w[x]+w[y]<W){
cout<<0<<endl;
continue;
}
cout<<(ll)(W-w[z]+1)*(H-h[z]+1)*2%mod<<endl;
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3528kb
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: 3532kb
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: 1ms
memory: 3560kb
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: 2ms
memory: 3536kb
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 777777757 456790164 0 0 0 0 0 6 222222210 555555535 135802502 0 0 0 0 6 222222212 222222208 333333309 814814847 0 0 0 6 222222212 222222210 222222208 111111089 493827185 0 0 6 222222208 222222212 222222212 222222210 888888876 172839523 0 6 222222212 222222212 222222212 222222212 222222...
result:
wrong answer 8th numbers differ - expected: '777777753', found: '777777757'