QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#511089 | #7785. Three Rectangles | ideograph_advantage# | WA | 0ms | 3620kb | C++17 | 2.5kb | 2024-08-09 16:04:14 | 2024-08-09 16:04:14 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define iter(v) v.begin(), v.end()
#define SZ(v) int(v.size())
#define pb emplace_back
#define ff first
#define ss second
#define fs ff
#define sc ss
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#ifdef zisk
void debug(){cerr << "\n";}
template<class T, class ... U>
void debug(T a, U ... b){cerr << a << " ", debug(b...);}
template<class T> void pary(T l, T r){
while (l != r) cerr << *l << " ", l++;
cerr << "\n";
}
#else
#define debug(...) void()
#define pary(...) void()
#endif
template<class A, class B>
ostream &operator<<(ostream& o, pair<A, B> p) {
return o << '(' << p.ff << ',' << p.ss << ')';
}
const int mod=1e9+7;
void add(int& a,int b){
a+=b;
a-=mod*(a>=mod);
a+=mod*(a<0);
}
int mul(int a,int b){
return 1ll*a*b%mod;
}
int h,w;
int get(pair<int,int> x){
return mul((h-x.fs+1),(w-x.sc+1));
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while(t--){
cin >> h >> w;
vector<pair<int,int> > v(3);
cin >> v[0].fs >> v[0].sc >> v[1].fs >> v[1].sc >> v[2].fs >> v[2].sc;
if(v[0].fs==h && v[0].sc==w){
cout << mul(get(v[1]),get(v[2])) << "\n";
}
else if(v[1].fs==h && v[1].sc==w){
cout << mul(get(v[0]),get(v[2])) << "\n";
}
else if(v[2].fs==h && v[2].sc==w){
cout << mul(get(v[0]),get(v[1])) << "\n";
}
else{
int a=0,b=0;
for(int i=0;i<3;i++){
if(v[i].fs==h){
a++;
}
if(v[i].sc==w){
b++;
}
}
if(b>a){
swap(h,w);
for(int i=0;i<3;i++){
swap(v[i].fs,v[i].sc);
}
swap(a,b);
}
//debug(a,b);
if(a==3){
if(v[0].sc+v[1].sc+v[2].sc<w){
cout << 0 << "\n";
}
else{
int ans=0;
for(int i=0;i<3;i++){
if(v[i].sc+v[(i+1)%3].sc>=w){
add(ans,mul(2,w-v[(i+2)%3].sc-1));
}
else{
int l=max(1,w-v[(i+1)%3].sc-v[(i+2)%3].sc);
int r=min(w-v[(i+2)%3].sc-1,v[i].sc);
add(ans,mul(2,r-l+1));
}
}
for(int i=0;i<3;i++){
if(max(v[i].sc,v[(i+1)%3].sc)+v[(i+2)%3].sc>=w){
add(ans,2);
}
}
cout << ans << "\n";
}
}
else if(a==2){
sort(v.begin(),v.end(),greater<>());
if(v[0].sc+v[1].sc>=w){
cout << mul(2,get(v[2])) << "\n";
}
else{
cout << 0 << "\n";
}
}
else if(a==1){
sort(v.begin(),v.end(),greater<>());
if(v[1].fs+v[2].fs>=h && v[0].sc+min(v[1].sc,v[2].sc)>=w){
cout << 4 << "\n";
}
else{
cout << 0 << "\n";
}
}
else{
cout << 0 << "\n";
}
}
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3620kb
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: 3500kb
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: 3544kb
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: 3604kb
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'