Skip to content

Commit cbf3416

Browse files
committed
split up rmq test
1 parent da3e8da commit cbf3416

File tree

4 files changed

+54
-37
lines changed

4 files changed

+54
-37
lines changed

tests/library_checker_aizu_tests/data_structures/rmq_all_methods.test.cpp

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#define PROBLEM "https://judge.yosupo.jp/problem/staticrmq"
2+
#include "../template.hpp"
3+
#include "../../../library/data_structures/uncommon/disjoint_rmq.hpp"
4+
int main() {
5+
cin.tie(0)->sync_with_stdio(0);
6+
int n, q;
7+
cin >> n >> q;
8+
vector<int> a(n);
9+
for (int i = 0; i < n; i++) cin >> a[i];
10+
disjoint_rmq dis_rmq(a, ranges::min);
11+
while (q--) {
12+
int l, r;
13+
cin >> l >> r;
14+
cout << dis_rmq.query(l, r) << '\n';
15+
}
16+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#define PROBLEM "https://judge.yosupo.jp/problem/staticrmq"
2+
#include "../template.hpp"
3+
#include "../../../library/data_structures/uncommon/linear_rmq.hpp"
4+
int main() {
5+
cin.tie(0)->sync_with_stdio(0);
6+
int n, q;
7+
cin >> n >> q;
8+
vector<int> a(n);
9+
for (int i = 0; i < n; i++) cin >> a[i];
10+
linear_rmq lin_rmq(a, less());
11+
while (q--) {
12+
int l, r;
13+
cin >> l >> r;
14+
int idx_min = lin_rmq.query_idx(l, r - 1);
15+
assert(l <= idx_min && idx_min < r);
16+
assert(lin_rmq.query(l, r - 1) == a[idx_min]);
17+
cout << a[idx_min] << '\n';
18+
}
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#define PROBLEM "https://judge.yosupo.jp/problem/staticrmq"
2+
#include "../template.hpp"
3+
#include "../mono_st_asserts.hpp"
4+
#include "../../../library/data_structures/rmq.hpp"
5+
int mn(int x, int y) { return min(x, y); }
6+
int main() {
7+
cin.tie(0)->sync_with_stdio(0);
8+
int n, q;
9+
cin >> n >> q;
10+
vector<int> a(n);
11+
for (int i = 0; i < n; i++) cin >> a[i];
12+
mono_st_asserts(a);
13+
RMQ rmq(a, ranges::min);
14+
while (q--) {
15+
int l, r;
16+
cin >> l >> r;
17+
cout << rmq.query(l, r) << '\n';
18+
}
19+
}

0 commit comments

Comments
 (0)