summaryrefslogtreecommitdiff
path: root/test/other
diff options
context:
space:
mode:
Diffstat (limited to 'test/other')
-rw-r--r--test/other/bitOps.cpp6
-rw-r--r--test/other/josephus2.cpp4
-rw-r--r--test/other/josephusK.cpp4
-rw-r--r--test/other/pbs.cpp6
-rw-r--r--test/other/sos.cpp4
5 files changed, 11 insertions, 13 deletions
diff --git a/test/other/bitOps.cpp b/test/other/bitOps.cpp
index 44f6297..2250521 100644
--- a/test/other/bitOps.cpp
+++ b/test/other/bitOps.cpp
@@ -31,9 +31,7 @@ ll naive(ll x) {
bits.push_back(x & 1);
x >>= 1;
}
- reverse(all(bits));
- next_permutation(all(bits));
- reverse(all(bits));
+ ranges::next_permutation(bits | views::reverse);
x = 0;
for (ll i = 0, j = 1; i < 64; i++, j <<= 1) {
if (bits[i] != 0) x |= j;
@@ -56,4 +54,4 @@ void test_nextPerm() {
int main() {
test_subsets();
test_nextPerm();
-} \ No newline at end of file
+}
diff --git a/test/other/josephus2.cpp b/test/other/josephus2.cpp
index 85a9d28..c6b1cd1 100644
--- a/test/other/josephus2.cpp
+++ b/test/other/josephus2.cpp
@@ -4,8 +4,8 @@
template<ll O>
ll naive(ll n, ll k) {
vector<ll> state(n);
- iota(all(state), O);
- for (ll i = k-1; state.size() > 1; i = (i + k - 1) % sz(state)) {
+ iota(begin(state), end(state), O);
+ for (ll i = k-1; state.size() > 1; i = (i + k - 1) % ssize(state)) {
state.erase(state.begin() + i);
}
return state[0];
diff --git a/test/other/josephusK.cpp b/test/other/josephusK.cpp
index e837640..1a5aa9d 100644
--- a/test/other/josephusK.cpp
+++ b/test/other/josephusK.cpp
@@ -5,8 +5,8 @@
template<ll O>
ll naive(ll n, ll k) {
vector<ll> state(n);
- iota(all(state), O);
- for (ll i = k-1; state.size() > 1; i = (i + k - 1) % sz(state)) {
+ iota(begin(state), end(state), O);
+ for (ll i = k-1; state.size() > 1; i = (i + k - 1) % ssize(state)) {
state.erase(state.begin() + i);
}
return state[0];
diff --git a/test/other/pbs.cpp b/test/other/pbs.cpp
index ba3b9d0..e1dfea0 100644
--- a/test/other/pbs.cpp
+++ b/test/other/pbs.cpp
@@ -49,7 +49,7 @@ void stress_test() {
for (int i=1; i<n; i++) {
edges.emplace_back(Random::integer(0, i), i);
}
- shuffle(all(edges), Random::rng);
+ ranges::shuffle(edges, Random::rng);
queries.clear();
for (int i=0; i<Q; i++) {
auto x = Random::distinct(2, n);
@@ -80,7 +80,7 @@ void performance_test() {
for (int i=1; i<n; i++) {
edges.emplace_back(Random::integer(0, i), i);
}
- shuffle(all(edges), Random::rng);
+ ranges::shuffle(edges, Random::rng);
queries.clear();
for (int i=0; i<Q; i++) {
auto x = Random::distinct(2, n);
@@ -91,7 +91,7 @@ void performance_test() {
t.start();
vector<int> ans = pbs(Q, MAX_OPERATIONS);
t.stop();
- ll hash = accumulate(all(ans), 0LL);
+ ll hash = accumulate(begin(ans), end(ans), 0LL);
if (t.time > 700) cerr << "too slow: " << t.time << FAIL;
cerr << "tested performance: " << t.time << "ms (hash: " << hash << ")" << endl;
diff --git a/test/other/sos.cpp b/test/other/sos.cpp
index f3a6109..3ab34ea 100644
--- a/test/other/sos.cpp
+++ b/test/other/sos.cpp
@@ -6,8 +6,8 @@ vector<ll> sos(const vector<ll>& in) {
}
vector<ll> naive(const vector<ll>& in) {
- vector<ll> res(sz(in));
- for (ll i = 0; i < sz(in); i++) {
+ vector<ll> res(ssize(in));
+ for (ll i = 0; i < ssize(in); i++) {
for (ll j = 0; j <= i; j++) {
if ((i | j) == i) {
res[i] += in[j];