-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.h
More file actions
71 lines (64 loc) · 1.72 KB
/
main.h
File metadata and controls
71 lines (64 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#ifdef PRINT_TIMING
#include <chrono>
#endif
#include <iomanip>
#include <iostream>
template <typename input_t>
struct solve_main_wrapper {
input_t& cin;
solve_main_wrapper(input_t& _cin, int argc, char** argv) : cin(_cin) {
(void)argc;
(void)argv;
}
void solve_main(int testnum);
int solve_all() {
int test_cases = 1;
#if defined(MULTI_TEST) or defined(PRINT_CASE)
cin >> test_cases;
#endif
for (int testnum = 1; testnum <= test_cases; testnum++) {
#define MAKE_STRING_IMPL(STRING) #STRING
#define MAKE_STRING(STRING) MAKE_STRING_IMPL(STRING)
#ifdef PRINT_CASE
std::cout << "Case " << MAKE_STRING(PRINT_CASE) << testnum << ": ";
#undef MAKE_STRING
#undef MAKE_STRING_IMPL
#endif
#ifdef PRINT_TIMING
auto start_time = std::chrono::high_resolution_clock::now();
#endif
solve_main(testnum);
#ifdef PRINT_TIMING
auto duration = std::chrono::high_resolution_clock::now() - start_time;
using namespace std::chrono;
std::cerr << "\n[t" << testnum << "] " << duration / 1.0s << "s\n\n";
#endif
}
return 0;
}
};
int main(int argc, char** argv) {
std::cout << std::fixed << std::setprecision(10);
#ifdef USING_FAST_INPUT
fast_input cin;
solve_main_wrapper solver(cin, argc, argv);
#else
std::cin.tie(0)->sync_with_stdio(0);
solve_main_wrapper solver(std::cin, argc, argv);
#endif
return solver.solve_all();
}
#define SOLVE() \
template <typename input_t> \
void solve_main_wrapper<input_t>::solve_main([[maybe_unused]] int testnum)
#include <random>
inline auto rng() -> std::mt19937& {
static std::random_device _rd;
static std::mt19937 _rng(_rd());
return _rng;
}
using ll = long long;
constexpr char nl = '\n';
#include <cassert>
using namespace std;