QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#768698 | #7785. Three Rectangles | SGColin# | WA | 1ms | 4032kb | C++14 | 4.2kb | 2024-11-21 13:45:57 | 2024-11-21 13:45:58 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tii;
typedef vector<int> vi;
inline int rd() {
int x = 0;
bool f = 0;
char c = getchar();
for (; !isdigit(c); c = getchar()) f |= (c == '-');
for (; isdigit(c); c = getchar()) x = x * 10 + (c ^ 48);
return f ? -x : x;
}
#define eb emplace_back
#define all(s) (s).begin(), (s).end()
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
constexpr int N = 5007;
struct rectan {
int h, w;
bool operator < (const rectan &obj) const {return h == obj.h ? (w < obj.w) : (h < obj.h);}
bool operator > (const rectan &obj) const {return obj < (*this);}
bool operator == (const rectan &obj) const {return !((*this) < obj || (*this) > obj);}
bool operator != (const rectan &obj) const {return !(*this == obj);}
bool operator <= (const rectan &obj) const {return !(*this > obj);}
bool operator >= (const rectan &obj) const {return !(*this < obj);}
};
const int mod = 1000000007;
inline void calc() {
rectan R{rd(), rd()};
vector<rectan> r;
int HW = 0, H = 0, W = 0;
rep(i, 1, 3) {
rectan rr{rd(), rd()};
if(rr.h == R.h && rr.w == R.w) HW++;
if(rr.h == R.h) H++;
if(rr.w == R.w) W++;
r.eb(rr);
}
if (HW > 0) {
int ans = 1;
for(auto rr : r) {
int res = 1ll * (R.h - rr.h + 1) * (R.w - rr.w + 1) % mod;
ans = (1ll * ans * res) % mod;
}
printf("%d\n", ans);
return;
}
if (W > 0) {
int ans = 0;
if (W == 3) {
sort(all(r));
do {
if (r[0].h + r[2].h >= R.h) ans = (ans + R.h - 1 - r[1].h) % mod;
else {
int low = max(R.h - r[2].h - r[1].h + 1, 2);
int up = min(R.h - r[1].h, r[0].h + 1);
if (low <= up) ans = (ans + up - low + 1) % mod;
}
}while (next_permutation(all(r)));
sort(all(r));
if (r[0].h + r[2].h >= R.h) ans = (ans + 2) % mod;
if (r[1].h + r[2].h >= R.h) ans = (ans + 4) % mod;
}
else if (W == 2) {
if (r[0].w != R.w) swap(r[0], r[2]);
if (r[1].w != R.w) swap(r[1], r[2]);
if (r[0].h + r[1].h >= R.h) ans = (ans + 2ll * (R.h - r[2].h +1) * (R.w - r[2].w + 1) % mod) % mod;
}
else if (W == 1) {
if (r[1].w == R.w) swap(r[1], r[0]);
if (r[2].w == R.w) swap(r[2], r[0]);
if(r[1].w + r[2].w >= R.w && r[1].h + r[0].h >= R.h && r[2].h + r[0].h >= R.h) ans = (ans + 4) % mod;
}
printf("%d\n", ans);
return;
}
if (H > 0) {
int ans = 0;
if (H == 3) {
sort(all(r));
do {
if (r[0].w + r[2].w >= R.w) ans = (ans + R.w - r[1].w - 1) % mod;
else {
int low = max(R.w - r[2].w - r[1].w + 1, 2);
int up = min(R.w - r[1].w, r[0].w + 1);
if (low <= up) ans = (ans + up - low + 1) % mod;
}
}while (next_permutation(all(r)));
sort(all(r));
if (r[0].w + r[2].w >= R.w) ans = (ans + 2) % mod;
if (r[1].w + r[2].w >= R.w) ans = (ans + 4) % mod;
}
else if (H == 2) {
if (r[0].h != R.h) swap(r[0], r[2]);
if (r[1].h != R.h) swap(r[1], r[2]);
if (r[0].w + r[1].w >= R.w) ans = (ans + 2ll * (R.w - r[2].w +1) * (R.h - r[2].h + 1) % mod) % mod;
}
else if (H == 1) {
if (r[1].h == R.h) swap(r[1], r[0]);
if (r[2].h == R.h) swap(r[2], r[0]);
if(r[1].h + r[2].h >= R.h && r[1].w + r[0].w >= R.w && r[2].w + r[0].w >= R.w) ans = (ans + 4) % mod;
}
printf("%d\n", ans);
return;
}
puts("0");
return;
}
int main() {
per(i, rd(), 1) calc();
return 0;
}
/*
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
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 4032kb
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: 3808kb
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: 4032kb
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: 3744kb
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 3 888888883 456790164 0 0 0 0 0 6 222222208 555555531 135802502 0 0 0 0 6 222222208 222222208 333333309 814814847 0 0 0 3 222222208 222222208 222222208 111111087 493827185 0 0 6 222222208 111111106 222222208 222222208 888888872 172839523 0 6 222222208 222222208 222222208 111111106 222222...
result:
wrong answer 7th numbers differ - expected: '6', found: '3'