QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#280901 | #7785. Three Rectangles | ucup-team1303# | WA | 23ms | 3488kb | C++20 | 3.6kb | 2023-12-09 18:20:40 | 2023-12-09 18:20:40 |
Judging History
answer
// MagicDark
#include <bits/stdc++.h>
#define debug cerr << "[" << __LINE__ << "] "
#define SZ(x) (int) x.size() - 1
#define all(x) x.begin(), x.end()
#define ms(x, y) memset(x, y, sizeof x)
#define F(i, x, y) for (int i = (x); i <= (y); i++)
#define DF(i, x, y) for (int i = (x); i >= (y); i--)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
template <typename T> inline void chkmax(T &x, T y) {x = max(x, y);}
template <typename T> inline void chkmin(T &x, T y) {x = min(x, y);}
template <typename T> inline void read(T &x) {
x = 0; int f = 1; char c = getchar();
for (; !isdigit(c); c = getchar()) if (c == '-') f = -f;
for (; isdigit(c); c = getchar()) x = (x << 1) + (x << 3) + (c ^ 48);
x *= f;
}
constexpr int MOD = 1e9 + 7;
int n, m, x[5], y[5], f[5][16], ans;
inline void add(int &x, ll y) {x = (x + y) % MOD;}
const vector <int> T = {0, 1, 2, 3, 4, 5, 8, 10, 12};
void dfs(int x, int a, int b, int c, int d, int e, int f, int g, int h, int t) {
if (x == 4) {
if (b + c >= n && d + e >= m && f + g >= n && a + h >= m) add(ans, t);
return;
}
for (int i: T) if (::f[x][i]) {
int aa = a, bb = b, cc = c, dd = d, ee = e, ff = f, gg = g, hh = h;
if (i & 1) chkmax(aa, ::y[x]), chkmax(bb, ::x[x]);
if (i & 2) chkmax(cc, ::x[x]), chkmax(dd, ::y[x]);
if (i & 4) chkmax(ee, ::y[x]), chkmax(ff, ::x[x]);
if (i & 8) chkmax(gg, ::x[x]), chkmax(hh, ::y[x]);
dfs(x + 1, aa, bb, cc, dd, ee, ff, gg, hh, (ll) t * ::f[x][i] % MOD);
}
}
void zhk() {
ans = 0;
cin >> n >> m;
bool flag = false, f1 = true, f2 = true;
F(i, 1, 3) {
ms(f[i], 0);
cin >> x[i] >> y[i];
f1 &= x[i] == n;
f2 &= y[i] == m;
if (x[i] == n && y[i] == m) flag = true;
if (x[i] == n) {
// f[i][7]++;
// f[i][11]++;
f[i][3]++;
f[i][12]++;
f[i][0] += m - y[i] - 1;
} else {
if (y[i] == m) {
f[i][5]++;
f[i][10]++;
f[i][0] += n - x[i] - 1;
} else {
f[i][1]++;
f[i][2]++;
f[i][4]++;
f[i][8]++;
f[i][0] += ((ll) (n - x[i] + 1) * (m - y[i] + 1) - 4) % MOD;
}
}
// for (int j: T) if (f[i][j]) {
// debug << i << " " << j << " " << f[i][j] << endl;
// }
}
if (flag) {
int s = 1;
F(i, 1, 3) s = (ll) s * (n - x[i] + 1) % MOD * (m - y[i] + 1) % MOD;
cout << s << '\n';
return;
}
dfs(1, 0, 0, 0, 0, 0, 0, 0, 0, 1);
// debug << ans << endl;
if (f1) {
F(i, 1, 3)
F(j, 1, 3) if (i != j) {
F(k, 1, 3) if (k != i && k != j) {
if (y[i] + y[j] < m && y[i] + y[j] + y[k] >= m) {
int t = y[i] + y[j] + y[k] - m;
add(ans, (ll) min(t, y[i] - 1) - max(0, t - (y[j] - 1)) + 1);
}
}
}
}
if (f2) {
F(i, 1, 3)
F(j, 1, 3) if (i != j) {
F(k, 1, 3) if (k != i && k != j) {
if (x[i] + x[j] < n && x[i] + x[j] + x[k] >= n) {
int t = x[i] + x[j] + x[k] - n;
add(ans, (ll) min(t, x[i] - 1) - max(0, t - (x[j] - 1)) + 1);
}
}
}
}
cout << ans << '\n';
// for (i: vector <int> {0, 1, 2, 3, 4, 5, 8, 10, 12}) {
// }
// int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
// if ((a == n && b == m) || (c == n && d == m) || (e == n && f == m)) {
// cout << (ll) (n - a + 1) * (m - b + 1) % MOD * (n - c + 1) % MOD * (m - d + 1) % MOD * (n - e + 1) % MOD * (m - f + 1) % MOD << '\n';
// return;
// }
// if (a != n && c != n && e != n && b != m && d != m && f != m) {
// cout << "0\n";
// return;
// }
// if (b != m && d != m && f != m) {
// cout << "0\n";
// return;
// }
}
signed main() {
int _ = 1;
cin >> _;
while (_--) zhk();
return 0;
}
/* why?
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3468kb
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: 3488kb
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: 3412kb
input:
1 1000000000 1000000000 1 1 1 1 1000000000 1000000000
output:
2401
result:
ok 1 number(s): "2401"
Test #4:
score: 0
Accepted
time: 3ms
memory: 3412kb
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:
ok 729 numbers
Test #5:
score: -100
Wrong Answer
time: 23ms
memory: 3420kb
input:
5832 999999999 222222222 111111111 111111111 111111111 111111111 111111111 111111111 222222222 999999999 111111111 111111111 111111111 111111111 111111111 222222222 222222222 999999999 111111111 111111111 111111111 111111111 111111111 333333333 999999999 222222222 111111111 111111111 111111111 11111...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 413046795 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 4 989330902 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 4 565615002 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 4 141899102 0 0 0 0 0 0 0 0 4 0 0 0 0 0 0 0 4 718183209 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 294467309 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 87...
result:
wrong answer 27th numbers differ - expected: '0', found: '4'