mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-30 16:16:28 +00:00
#1702. 【CSP-S 2022】策略游戏(game,民间数据)
https://sjzezoj.com/submission/62996
This commit is contained in:
parent
b3f60c8d77
commit
07e69976a1
169
S2OJ/1702/1702.cpp
Normal file
169
S2OJ/1702/1702.cpp
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 1e5 + 5;
|
||||||
|
const long long INF = 0x3f3f3f3f3f3f3f3f;
|
||||||
|
|
||||||
|
int n, m, q;
|
||||||
|
long long a[N], b[N];
|
||||||
|
|
||||||
|
struct node {
|
||||||
|
int l, r, cnt;
|
||||||
|
long long min, max;
|
||||||
|
|
||||||
|
node(int _l = 0, int _r = 0)
|
||||||
|
: l(_l), r(_r), cnt(0), min(INF), max(-INF) {}
|
||||||
|
} tr1a[N << 2], tr1b[N << 2], tr2a[N << 2], tr2b[N << 2];
|
||||||
|
|
||||||
|
void pushup(node* tr, int u) {
|
||||||
|
tr[u].cnt = tr[u << 1].cnt + tr[u << 1 | 1].cnt;
|
||||||
|
tr[u].min = std::min(tr[u << 1].min, tr[u << 1 | 1].min);
|
||||||
|
tr[u].max = std::max(tr[u << 1].max, tr[u << 1 | 1].max);
|
||||||
|
}
|
||||||
|
|
||||||
|
void build1(node* tr, long long* a, int u, int l, int r) {
|
||||||
|
tr[u] = node(l, r);
|
||||||
|
|
||||||
|
if (l == r) {
|
||||||
|
if (a[l] >= 0) {
|
||||||
|
tr[u].max = tr[u].min = a[l];
|
||||||
|
tr[u].cnt = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mid = l + r >> 1;
|
||||||
|
|
||||||
|
build1(tr, a, u << 1, l, mid);
|
||||||
|
build1(tr, a, u << 1 | 1, mid + 1, r);
|
||||||
|
|
||||||
|
pushup(tr, u);
|
||||||
|
}
|
||||||
|
|
||||||
|
void build2(node* tr, long long* a, int u, int l, int r) {
|
||||||
|
tr[u] = node(l, r);
|
||||||
|
|
||||||
|
if (l == r) {
|
||||||
|
if (a[l] <= 0) {
|
||||||
|
tr[u].max = tr[u].min = a[l];
|
||||||
|
tr[u].cnt = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mid = l + r >> 1;
|
||||||
|
|
||||||
|
build2(tr, a, u << 1, l, mid);
|
||||||
|
build2(tr, a, u << 1 | 1, mid + 1, r);
|
||||||
|
|
||||||
|
pushup(tr, u);
|
||||||
|
}
|
||||||
|
|
||||||
|
long long query_min(node* tr, int u, int l, int r) {
|
||||||
|
if (l <= tr[u].l && tr[u].r <= r) return tr[u].min;
|
||||||
|
|
||||||
|
int mid = tr[u].l + tr[u].r >> 1;
|
||||||
|
long long res = INF;
|
||||||
|
|
||||||
|
if (l <= mid) res = std::min(res, query_min(tr, u << 1, l, r));
|
||||||
|
if (r > mid) res = std::min(res, query_min(tr, u << 1 | 1, l, r));
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
long long query_max(node* tr, int u, int l, int r) {
|
||||||
|
if (l <= tr[u].l && tr[u].r <= r) return tr[u].max;
|
||||||
|
|
||||||
|
int mid = tr[u].l + tr[u].r >> 1;
|
||||||
|
long long res = -INF;
|
||||||
|
|
||||||
|
if (l <= mid) res = std::max(res, query_max(tr, u << 1, l, r));
|
||||||
|
if (r > mid) res = std::max(res, query_max(tr, u << 1 | 1, l, r));
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
int query_cnt(node* tr, int u, int l, int r) {
|
||||||
|
if (l <= tr[u].l && tr[u].r <= r) return tr[u].cnt;
|
||||||
|
|
||||||
|
int mid = tr[u].l + tr[u].r >> 1;
|
||||||
|
int cnt = 0;
|
||||||
|
|
||||||
|
if (l <= mid) cnt += query_cnt(tr, u << 1, l, r);
|
||||||
|
if (r > mid) cnt += query_cnt(tr, u << 1 | 1, l, r);
|
||||||
|
|
||||||
|
return cnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> n >> m >> q;
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
cin >> a[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= m; i++) {
|
||||||
|
cin >> b[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
build1(tr1a, a, 1, 1, n);
|
||||||
|
build2(tr1b, a, 1, 1, n);
|
||||||
|
build1(tr2a, b, 1, 1, m);
|
||||||
|
build2(tr2b, b, 1, 1, m);
|
||||||
|
|
||||||
|
while (q--) {
|
||||||
|
int l1, r1, l2, r2;
|
||||||
|
|
||||||
|
cin >> l1 >> r1 >> l2 >> r2;
|
||||||
|
|
||||||
|
long long max_1a = query_max(tr1a, 1, l1, r1),
|
||||||
|
min_1a = query_min(tr1a, 1, l1, r1);
|
||||||
|
long long max_1b = query_max(tr1b, 1, l1, r1),
|
||||||
|
min_1b = query_min(tr1b, 1, l1, r1);
|
||||||
|
long long max_2a = query_max(tr2a, 1, l2, r2),
|
||||||
|
min_2a = query_min(tr2a, 1, l2, r2);
|
||||||
|
long long max_2b = query_max(tr2b, 1, l2, r2),
|
||||||
|
min_2b = query_min(tr2b, 1, l2, r2);
|
||||||
|
|
||||||
|
int cnt_1a = query_cnt(tr1a, 1, l1, r1),
|
||||||
|
cnt_1b = query_cnt(tr1b, 1, l1, r1);
|
||||||
|
int cnt_2a = query_cnt(tr2a, 1, l2, r2),
|
||||||
|
cnt_2b = query_cnt(tr2b, 1, l2, r2);
|
||||||
|
|
||||||
|
if (!cnt_1a) { // 1. [l1, r1] 间无正数
|
||||||
|
if (!cnt_2a) { // a. [l2, r2] 间无正数
|
||||||
|
cout << min_1b * max_2b << endl;
|
||||||
|
} else if (!cnt_2b) { // b [l2, r2] 间无负数
|
||||||
|
cout << max_1b * max_2a << endl;
|
||||||
|
} else {
|
||||||
|
cout << max_1b * max_2a << endl;
|
||||||
|
}
|
||||||
|
} else if (!cnt_1b) { // 2. [l1, r1] 间无负数
|
||||||
|
if (!cnt_2a) { // a. [l2, r2] 间无正数
|
||||||
|
cout << min_1a * min_2b << endl;
|
||||||
|
} else if (!cnt_2b) { // b [l2, r2] 间无负数
|
||||||
|
cout << max_1a * min_2a << endl;
|
||||||
|
} else {
|
||||||
|
cout << min_1a * min_2b << endl;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!cnt_2a) { // a. [l2, r2] 间无正数
|
||||||
|
cout << min_1b * max_2b << endl;
|
||||||
|
} else if (!cnt_2b) { // b [l2, r2] 间无负数
|
||||||
|
cout << max_1a * min_2a << endl;
|
||||||
|
} else {
|
||||||
|
cout << std::max(max_1b * max_2a, min_1a * min_2b) << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
S2OJ/1702/data/ex_game1.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/ex_game1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/ex_game1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/ex_game1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/ex_game2.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/ex_game2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/ex_game2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/ex_game2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/ex_game3.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/ex_game3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/ex_game3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/ex_game3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/ex_game4.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/ex_game4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/ex_game4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/ex_game4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game1.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game1.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game1.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game10.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game10.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game10.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game11.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game11.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game11.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game12.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game12.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game12.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game13.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game13.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game13.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game14.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game14.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game14.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game15.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game15.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game15.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game16.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game16.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game16.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game16.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game17.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game17.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game17.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game17.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game18.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game18.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game18.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game18.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game19.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game19.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game19.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game19.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game2.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game2.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game2.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game20.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game20.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game20.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game20.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game3.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game3.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game3.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game4.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game4.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game4.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game5.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game5.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game5.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game6.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game6.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game6.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game7.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game7.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game7.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game8.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game8.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game8.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game9.ans
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game9.ans
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/game9.in
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/game9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
S2OJ/1702/data/problem.conf
(Stored with Git LFS)
Normal file
BIN
S2OJ/1702/data/problem.conf
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user