1829(cpp): solve contest

* “A. Love Story”
* “B. Blank Space”
* “C. Mr. Perfectly Fine”
* “D. Gold Rush”
* “E. The Lakes”
* “F. Forewer Winter”
* “G. Hits Different”
* “H. Don't Blame Me”

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2023-07-23 11:31:12 +02:00
parent 6589b762d9
commit 0bfc6f808e
Signed by: mfocko
GPG key ID: 7C47D46246790496
9 changed files with 2533 additions and 0 deletions

97
1829/a.cpp Normal file
View file

@ -0,0 +1,97 @@
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <functional>
#include <iostream>
#include <optional>
#include <sstream>
#include <string>
#include <vector>
namespace helpers {
using namespace std;
long pow(long base, long exp) {
if (exp == 0) return 1;
long half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
template <typename T>
inline void answer(const T& ans) {
cout << ans << "\n";
}
inline void yes() { cout << "YES\n"; }
inline void no() { cout << "NO\n"; }
} // namespace helpers
namespace {
using namespace std;
using namespace helpers;
static const string S("codeforces");
int differs(const string& s) {
int counter = 0;
for (auto i = 0u; i < S.size(); ++i) {
if (s[i] != S[i]) {
++counter;
}
}
return counter;
}
void solve() {
string s;
cin >> s;
answer(differs(s));
}
} // namespace
// for single test case, comment out for N test cases
// #define SINGLE
#ifdef TEST
#include "../.common/cpp/catch_amalgamated.hpp"
TEST_CASE("examples") {
CHECK(differs("coolforsez") == 4);
CHECK(differs("cadafurcie") == 5);
CHECK(differs("codeforces") == 0);
CHECK(differs("paiuforces") == 4);
CHECK(differs("forcescode") == 9);
}
#else
int main(void) {
#ifdef SINGLE
solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solve();
}
#endif
return 0;
}
#endif

106
1829/b.cpp Normal file
View file

@ -0,0 +1,106 @@
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <functional>
#include <iostream>
#include <optional>
#include <sstream>
#include <string>
#include <vector>
namespace helpers {
using namespace std;
long pow(long base, long exp) {
if (exp == 0) return 1;
long half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
template <typename T>
inline void answer(const T& ans) {
cout << ans << "\n";
}
inline void yes() { cout << "YES\n"; }
inline void no() { cout << "NO\n"; }
} // namespace helpers
namespace {
using namespace std;
using namespace helpers;
int longest(const vector<int>& arr) {
int found = 0;
int current = 0;
for (auto i = 0u; i < arr.size(); ++i) {
if (arr[i] == 0) {
++current;
found = max(found, current);
} else {
current = 0;
}
}
return found;
}
void solve() {
int N;
cin >> N;
vector<int> arr(N);
for (auto i = 0; i < N; ++i) {
cin >> arr[i];
}
answer(longest(arr));
}
} // namespace
// for single test case, comment out for N test cases
// #define SINGLE
#ifdef TEST
#include "../.common/cpp/catch_amalgamated.hpp"
TEST_CASE("examples") {
CHECK(longest(vector<int>{1, 0, 0, 1, 0}) == 2);
CHECK(longest(vector<int>{0, 1, 1, 1}) == 1);
CHECK(longest(vector<int>{0}) == 1);
CHECK(longest(vector<int>{1, 1, 1}) == 0);
CHECK(longest(vector<int>{1, 0, 0, 0, 1, 0, 0, 0, 1}) == 3);
}
#else
int main(void) {
#ifdef SINGLE
solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solve();
}
#endif
return 0;
}
#endif

131
1829/c.cpp Normal file
View file

@ -0,0 +1,131 @@
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <functional>
#include <iostream>
#include <optional>
#include <sstream>
#include <string>
#include <vector>
namespace helpers {
using namespace std;
long pow(long base, long exp) {
if (exp == 0) return 1;
long half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
template <typename T>
inline void answer(const T &ans) {
cout << ans << "\n";
}
inline void yes() { cout << "YES\n"; }
inline void no() { cout << "NO\n"; }
#define LOOP(n) for (auto i = 0; i < n; ++i)
} // namespace helpers
namespace {
using namespace std;
using namespace helpers;
struct book {
int t;
string skills;
};
int find_minimum(const vector<book> &books) {
const int UNDEFINED = 400001;
int min_a = UNDEFINED;
int min_b = UNDEFINED;
int min_both = UNDEFINED;
for (const book &b : books) {
if (b.skills == "01") {
min_b = min(min_b, b.t);
} else if (b.skills == "10") {
min_a = min(min_a, b.t);
} else if (b.skills == "11") {
min_both = min(min_both, b.t);
}
}
if (min_a != UNDEFINED && min_b != UNDEFINED && min_a + min_b < min_both) {
return min_a + min_b;
} else if (min_both != UNDEFINED) {
return min_both;
}
return -1;
}
void solve() {
int N;
cin >> N;
vector<book> bs(N);
LOOP(N) {
int t;
string skills;
cin >> t >> skills;
bs[i] = {t, skills};
}
answer(find_minimum(bs));
}
} // namespace
// for single test case, comment out for N test cases
// #define SINGLE
#ifdef TEST
#include "../.common/cpp/catch_amalgamated.hpp"
TEST_CASE("examples") {
CHECK(find_minimum(
vector<book>{{2, "00"}, {3, "10"}, {4, "01"}, {4, "00"}}) == 7);
CHECK(find_minimum(vector<book>{
{3, "01"}, {3, "01"}, {5, "01"}, {2, "10"}, {9, "10"}}) == 5);
CHECK(find_minimum(vector<book>{{5, "11"}}) == 5);
CHECK(find_minimum(vector<book>{{9, "11"}, {8, "01"}, {7, "10"}}) == 9);
CHECK(
find_minimum(vector<book>{
{4, "01"}, {6, "01"}, {7, "01"}, {8, "00"}, {9, "01"}, {1, "00"}}) ==
-1);
CHECK(find_minimum(vector<book>{{{200000, "01"}, {200000, "10"}}}) == 400000);
}
#else
int main(void) {
#ifdef SINGLE
solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solve();
}
#endif
return 0;
}
#endif

118
1829/d.cpp Normal file
View file

@ -0,0 +1,118 @@
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <functional>
#include <iostream>
#include <optional>
#include <sstream>
#include <string>
#include <vector>
namespace helpers {
using namespace std;
long pow(long base, long exp) {
if (exp == 0) return 1;
long half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
template <typename T>
inline void answer(const T &ans) {
cout << ans << "\n";
}
inline void yes() { cout << "YES\n"; }
inline void no() { cout << "NO\n"; }
inline void yesno(bool ans) {
if (ans) {
yes();
} else {
no();
}
}
} // namespace helpers
namespace {
using namespace std;
using namespace helpers;
bool can_split(int n, int m) {
if (n == m) {
// we already have a pile
return true;
}
if (n < m) {
// cannot make bigger pile
return false;
}
if (n % 3 != 0) {
// cannot split the pile
return false;
}
int third = n / 3;
return can_split(third, m) || can_split(2 * third, m);
}
void solve() {
int n, m;
cin >> n >> m;
yesno(can_split(n, m));
}
} // namespace
// for single test case, comment out for N test cases
// #define SINGLE
#ifdef TEST
#include "../.common/cpp/catch_amalgamated.hpp"
TEST_CASE("examples") {
CHECK(can_split(6, 4));
CHECK(can_split(9, 4));
CHECK(!can_split(4, 2));
CHECK(!can_split(18, 27));
CHECK(can_split(27, 4));
CHECK(can_split(27, 2));
CHECK(!can_split(27, 10));
CHECK(can_split(1, 1));
CHECK(can_split(3, 1));
CHECK(!can_split(5, 1));
CHECK(!can_split(746001, 2984004));
}
#else
int main(void) {
#ifdef SINGLE
solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solve();
}
#endif
return 0;
}
#endif

197
1829/e.cpp Normal file
View file

@ -0,0 +1,197 @@
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <functional>
#include <iostream>
#include <optional>
#include <queue>
#include <sstream>
#include <string>
#include <vector>
namespace helpers {
using namespace std;
namespace math {
long pow(long base, long exp) {
if (exp == 0) return 1;
long half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
} // namespace math
namespace input {
template <typename T>
std::vector<T> load_vector(std::size_t size) {
std::vector<T> result{};
for (auto i = 0u; i < size; ++i) {
T x;
std::cin >> x;
result.push_back(std::move(x));
}
return result;
}
} // namespace input
namespace output {
template <typename T>
inline void answer(const T& ans) {
cout << ans << "\n";
}
inline void yes() { cout << "YES\n"; }
inline void no() { cout << "NO\n"; }
inline void yesno(bool ans) {
if (ans) {
yes();
} else {
no();
}
}
} // namespace output
using namespace math;
using namespace input;
using namespace output;
#define LOOP(n) for (auto i = 0; i < n; ++i)
} // namespace helpers
// for N test cases, uncomment for single test case
// #define SINGLE
namespace solution {
using namespace std;
using namespace helpers;
int run_bfs(vector<vector<int>>& grid, int y0, int x0) {
int volume = 0;
queue<pair<int, int>> q;
// handle first element separately
volume += grid[y0][x0];
grid[y0][x0] = 0;
q.push({y0, x0});
while (q.size()) {
auto [_y, _x] = q.front();
q.pop();
for (auto [dy, dx] :
vector<pair<int, int>>{{-1, 0}, {1, 0}, {0, -1}, {0, 1}}) {
auto y = _y + dy;
auto x = _x + dx;
if (y < 0 || y >= static_cast<int>(grid.size()) || x < 0 ||
x >= static_cast<int>(grid[y].size()) || grid[y][x] == 0) {
continue;
}
volume += grid[y][x];
grid[y][x] = 0;
q.push(pair{y, x});
}
}
return volume;
}
int largest_volume(vector<vector<int>> grid) {
int largest = 0;
for (auto y = 0; y < static_cast<int>(grid.size()); ++y) {
for (auto x = 0; x < static_cast<int>(grid[y].size()); ++x) {
if (grid[y][x] == 0) {
// ignore zeroes
continue;
}
largest = max(largest, run_bfs(grid, y, x));
}
}
return largest;
}
void solve() {
int n, m;
cin >> n >> m;
vector<vector<int>> grid;
LOOP(n) {
auto row = load_vector<int>(m);
grid.push_back(move(row));
}
answer(largest_volume(grid));
}
} // namespace solution
using namespace solution;
#ifdef TEST
#include "../.common/cpp/catch_amalgamated.hpp"
TEST_CASE("examples") {
CHECK(largest_volume(
vector{vector{1, 2, 0}, vector{3, 4, 0}, vector{0, 0, 5}}) == 10);
CHECK(largest_volume(vector<vector<int>>{vector{0}}) == 0);
CHECK(largest_volume(vector{
vector{0, 1, 1},
vector{1, 0, 1},
vector{1, 1, 1},
}) == 7);
CHECK(largest_volume(vector{
vector{1, 1, 1, 1, 1},
vector{1, 0, 0, 0, 1},
vector{1, 0, 5, 0, 1},
vector{1, 0, 0, 0, 1},
vector{1, 1, 1, 1, 1},
}) == 16);
CHECK(largest_volume(vector{
vector{1, 1, 1, 1, 1},
vector{1, 0, 0, 0, 1},
vector{1, 1, 4, 0, 1},
vector{1, 0, 0, 0, 1},
vector{1, 1, 1, 1, 1},
}) == 21);
}
#else
int main(void) {
#ifdef SINGLE
solution::solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solution::solve();
}
#endif
return 0;
}
#endif

206
1829/f.cpp Normal file
View file

@ -0,0 +1,206 @@
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <functional>
#include <iostream>
#include <map>
#include <optional>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
template <typename T, typename U>
std::ostream &operator<<(std::ostream &s, std::pair<T, U> const &p) {
return s << p.first << " " << p.second;
}
namespace helpers {
using namespace std;
namespace math {
long pow(long base, long exp) {
if (exp == 0) return 1;
long half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
} // namespace math
namespace input {
template <typename T>
std::vector<T> load_vector(std::size_t size) {
std::vector<T> result{};
for (auto i = 0u; i < size; ++i) {
T x;
std::cin >> x;
result.push_back(std::move(x));
}
return result;
}
} // namespace input
namespace output {
template <typename T>
inline void answer(const T &ans) {
cout << ans << "\n";
}
inline void yes() { cout << "YES\n"; }
inline void no() { cout << "NO\n"; }
inline void yesno(bool ans) {
if (ans) {
yes();
} else {
no();
}
}
} // namespace output
using namespace math;
using namespace input;
using namespace output;
#define LOOP(n) for (auto i = 0; i < n; ++i)
} // namespace helpers
// for N test cases, uncomment for single test case
// #define SINGLE
namespace solution {
using namespace std;
using namespace helpers;
struct vertex {
set<int> neighbours;
};
pair<int, int> determine_snowflake(const map<int, vertex> &vertices) {
map<int, int> counts;
int leaf_parent = -1;
for (const auto &mapping : vertices) {
auto v = mapping.second;
if (v.neighbours.size() == 1) {
leaf_parent = *v.neighbours.begin();
continue;
}
counts[v.neighbours.size()]++;
}
int y = vertices.at(leaf_parent).neighbours.size() - 1;
// V = 1 + x + x * y
// V - 1 = x + x * y
// V - 1 = x * (1 + y)
// x = (V - 1) / (y + 1)
int x = (vertices.size() - 1) / (y + 1);
return {x, y};
}
void solve() {
int V, E;
cin >> V >> E;
map<int, vertex> vertices;
LOOP(E) {
int u, v;
cin >> u >> v;
vertices[u].neighbours.insert(v);
vertices[v].neighbours.insert(u);
}
answer(determine_snowflake(vertices));
}
} // namespace solution
using namespace solution;
#ifdef TEST
#include "../.common/cpp/catch_amalgamated.hpp"
static map<int, vertex> edges_to_graph(vector<pair<int, int>> edges) {
map<int, vertex> vertices;
for (auto [u, v] : edges) {
vertices[u].neighbours.insert(v);
vertices[v].neighbours.insert(u);
}
return vertices;
}
TEST_CASE("examples") {
CHECK(determine_snowflake(edges_to_graph(vector<pair<int, int>>{
{21, 20}, {21, 20}, {5, 20}, {13, 20}, {1, 3}, {11, 3},
{10, 3}, {4, 8}, {19, 8}, {14, 8}, {9, 7}, {12, 7},
{17, 7}, {18, 6}, {16, 6}, {2, 6}, {6, 15}, {7, 15},
{8, 15}, {20, 15}, {3, 15}})) == pair{5, 3});
CHECK(determine_snowflake(edges_to_graph(vector<pair<int, int>>{
{7, 6}, {1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {3, 7}})) ==
pair{2, 2});
CHECK(determine_snowflake(edges_to_graph(vector<pair<int, int>>{
{9, 8},
{9, 3},
{3, 6},
{6, 2},
{2, 1},
{5, 2},
{2, 7},
{4, 3},
{3, 8},
})) == pair{2, 3});
CHECK(determine_snowflake(edges_to_graph(vector<pair<int, int>>{
{1, 2}, {1, 3}, {2, 4}, {2, 5}, {3, 6}, {3, 7}})) == pair{2, 2});
CHECK(determine_snowflake(edges_to_graph(vector<pair<int, int>>{
{1, 2}, {1, 3}, {1, 4}, {1, 5}, {1, 6}, {2, 21}, {2, 22},
{2, 23}, {2, 24}, {3, 31}, {3, 32}, {3, 33}, {3, 34}, {4, 41},
{4, 42}, {4, 43}, {4, 44}, {5, 51}, {5, 52}, {5, 53}, {5, 54},
{6, 61}, {6, 62}, {6, 63}, {6, 64},
})) == pair{5, 4});
}
#else
int main(void) {
#ifdef SINGLE
solution::solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solution::solve();
}
#endif
return 0;
}
#endif

193
1829/g.cpp Normal file
View file

@ -0,0 +1,193 @@
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <functional>
#include <iostream>
#include <map>
#include <optional>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
template <typename T, typename U>
std::ostream &operator<<(std::ostream &s, std::pair<T, U> const &p) {
return s << p.first << " " << p.second;
}
namespace helpers {
using namespace std;
namespace math {
uint32_t pow(uint32_t base, uint32_t exp) {
if (exp == 0) return 1;
uint32_t half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
} // namespace math
namespace input {
template <typename T>
std::vector<T> load_vector(std::size_t size) {
std::vector<T> result{};
for (auto i = 0u; i < size; ++i) {
T x;
std::cin >> x;
result.push_back(std::move(x));
}
return result;
}
} // namespace input
namespace output {
template <typename T>
inline void answer(const T &ans) {
cout << ans << "\n";
}
inline void yes() { cout << "YES\n"; }
inline void no() { cout << "NO\n"; }
inline void yesno(bool ans) {
if (ans) {
yes();
} else {
no();
}
}
} // namespace output
using namespace math;
using namespace input;
using namespace output;
#define LOOP(n) for (auto i = 0; i < n; ++i)
} // namespace helpers
// for N test cases, uncomment for single test case
// #define SINGLE
namespace solution {
using namespace std;
using namespace helpers;
constexpr array<int32_t, 2023> ROWS = []() {
array<int32_t, 2023> starts;
starts[0] = 1;
for (auto y = 1; y < 2023; ++y) {
starts[y] = starts[y - 1] + y;
}
return starts;
}();
int32_t find_row(int n) {
return distance(ROWS.begin(), upper_bound(ROWS.begin(), ROWS.end(), n)) - 1;
}
int32_t get_n(int y, int x) { return ROWS[y] + x; }
uint64_t sum_of_n_squared(uint64_t n) { return n * (n + 1) * (2 * n + 1) / 6; }
uint64_t add_row(int32_t lower, int32_t upper) {
return sum_of_n_squared(upper) - sum_of_n_squared(lower - 1);
}
uint64_t find_sum(int32_t n) {
auto y = find_row(n);
auto x_u = n - ROWS[y];
auto x_l = x_u;
uint64_t sum = 0;
for (; y >= 0; --y) {
auto lower = get_n(y, x_l);
auto upper = get_n(y, x_u);
sum += add_row(lower, upper);
x_l = max(0, x_l - 1);
x_u = min(x_u, y - 1);
}
return sum;
}
void solve() {
int n;
cin >> n;
answer(find_sum(n));
}
} // namespace solution
using namespace solution;
#ifdef TEST
#include "../.common/cpp/catch_amalgamated.hpp"
TEST_CASE("find row") {
CHECK(ROWS[find_row(1)] == 1);
CHECK(ROWS[find_row(2)] == 2);
CHECK(ROWS[find_row(3)] == 2);
for (int i = 11; i <= 15; ++i) {
CHECK(ROWS[find_row(i)] == 11);
}
}
TEST_CASE("examples") {
CHECK(find_sum(9) == 156);
CHECK(find_sum(1) == 1);
CHECK(find_sum(2) == 5);
CHECK(find_sum(3) == 10);
CHECK(find_sum(4) == 21);
CHECK(find_sum(5) == 39);
CHECK(find_sum(6) == 46);
CHECK(find_sum(10) == 146);
CHECK(find_sum(1434) == 63145186);
LOOP(1000) { CHECK(find_sum(1000000) == 58116199242129511); }
LOOP(100000) { find_sum(900000 + i); }
}
#else
int main(void) {
#ifdef SINGLE
solution::solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solution::solve();
}
#endif
return 0;
}
#endif

165
1829/h.cpp Normal file
View file

@ -0,0 +1,165 @@
#include <algorithm>
#include <bit>
#include <cassert>
#include <cctype>
#include <cstdint>
#include <functional>
#include <iostream>
#include <map>
#include <optional>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>
template <typename T, typename U>
std::ostream &operator<<(std::ostream &s, std::pair<T, U> const &p) {
return s << p.first << " " << p.second;
}
namespace helpers {
using namespace std;
namespace math {
static constexpr int MODULO = 1000000007;
long pow(long base, long exp) {
if (exp == 0) return 1;
long half = pow(base, exp / 2);
if (exp % 2 == 0) return half * half;
return half * half * base;
}
} // namespace math
namespace input {
template <typename T>
std::vector<T> load_vector(std::size_t size) {
std::vector<T> result{};
for (auto i = 0u; i < size; ++i) {
T x;
std::cin >> x;
result.push_back(std::move(x));
}
return result;
}
} // namespace input
namespace output {
template <typename T>
inline void answer(const T &ans) {
cout << ans << "\n";
}
inline void yes() { cout << "YES\n"; }
inline void no() { cout << "NO\n"; }
inline void yesno(bool ans) {
if (ans) {
yes();
} else {
no();
}
}
} // namespace output
using namespace math;
using namespace input;
using namespace output;
#define LOOP(n) for (auto i = 0; i < n; ++i)
} // namespace helpers
// for N test cases, uncomment for single test case
// #define SINGLE
namespace solution {
using namespace std;
using namespace helpers;
int find_ways(int k, const vector<int> &numbers) {
std::array<int, 64> counters{};
// try all possible ways
for (int x : numbers) {
std::array<int, 64> new_counters{};
for (int mask = 0; mask < 64; ++mask) {
new_counters[mask] = (new_counters[mask] + counters[mask]) % MODULO;
new_counters[mask & x] =
(new_counters[mask & x] + counters[mask]) % MODULO;
}
new_counters[x] = (new_counters[x] + 1) % MODULO;
counters = move(new_counters);
}
// sum up the found results
int counts = 0;
for (auto i = 0u; i < 64; ++i) {
if (popcount(i) == k) {
counts = (counts + counters[i]) % MODULO;
}
}
return counts;
}
void solve() {
int n, k;
cin >> n >> k;
auto numbers = load_vector<int>(n);
answer(find_ways(k, numbers));
}
} // namespace solution
using namespace solution;
#ifdef TEST
#include "../.common/cpp/catch_amalgamated.hpp"
TEST_CASE("examples") {
CHECK(find_ways(1, vector{1, 1, 1, 1, 1}) == 31);
CHECK(find_ways(0, vector{0, 1, 2, 3}) == 10);
CHECK(find_ways(1, vector{5, 5, 7, 4, 2}) == 10);
CHECK(find_ways(2, vector{3}) == 1);
CHECK(find_ways(0, vector{0, 2, 0, 2, 0, 2, 0, 2, 0, 2, 0, 2}) == 4032);
CHECK(find_ways(6, vector{63, 0, 63, 5, 5, 63, 63, 4, 12, 13}) == 15);
}
#else
int main(void) {
#ifdef SINGLE
solution::solve();
#else
// for multiple test cases
int N;
std::cin >> N >> std::ws;
for (auto i = 0; i < N; ++i) {
solution::solve();
}
#endif
return 0;
}
#endif

1320
1829/index.html Normal file

File diff suppressed because one or more lines are too long