Repository navigation
Expand file tree
/
Copy pathmain.cpp
More file actions
141 lines (116 loc) · 3.51 KB
/
Copy pathmain.cpp
File metadata and controls
141 lines (116 loc) · 3.51 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
#pragma GCC optimize("O3","inline")
#define FINAL_SUBMIT 0
#if FINAL_SUBMIT
#define NDEBUG
#endif
#include <bits/stdc++.h>
#if defined(__x86_64__) || defined(__i386__)
#include <immintrin.h>
#endif
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
#if FINAL_SUBMIT
#define HHH(x)
#define LOG(x)
#define FORCE_LOG(x) std::cerr << #x << " = " << x << "\n"
#define CERR() if (false) std::cerr
#else
#define HHH(x) std::cerr << "L" << __LINE__ << ": " << #x << " : " << (x) << "\n"
#define LOG(x) std::cerr << #x << " = " << x << "\n"
#define FORCE_LOG(x) std::cerr << #x << " = " << x << "\n"
#define CERR() std::cerr
#endif
template <typename T> T &chmin(T &a, const T &b) { return a = std::min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = std::max(a, b); }
using ll = long long;
using ld = double;
constexpr int INF = 1e9;
constexpr double PI = acos(-1.0);
template <typename T> T sq(T x) { return x * x; }
template <typename T, typename U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
return os << "(" << p.first << ", " << p.second << ")";
}
template <typename T> std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
os << "[";
for (const T& e : vec) os << " " << e;
os << " ]";
return os;
}
class Timer {
public:
int64_t start, stop;
#ifdef __aarch64__
static constexpr int64_t CYCLES_PER_SEC = 600000000;
inline int64_t get_cycle() const {
uint64_t t;
asm volatile("mrs %0, cntvct_el0" : "=r" (t));
return t;
}
#else
static constexpr int64_t CYCLES_PER_SEC = 2400000000;
inline int64_t get_cycle() const {
uint32_t low, high;
__asm__ volatile("rdtsc" : "=a"(low), "=d"(high));
return int64_t(low) | (int64_t(high) << 32);
}
#endif
Timer(double time_limit) : start(get_cycle()), stop(start + CYCLES_PER_SEC * time_limit) {}
inline void reset_stop(double time_limit) { stop = start + CYCLES_PER_SEC * time_limit; }
inline bool within(int64_t end) const { return get_cycle() < end; }
inline bool within() const { return within(stop); }
inline double elapsed() const { return (get_cycle() - start) / double(CYCLES_PER_SEC); }
};
class XorShift {
unsigned int x, y, z, w;
public:
XorShift() : x(314159265), y(358979323), z(846264338), w(327950288) {}
inline unsigned int next() {
unsigned int t = x ^ x << 11;
x = y; y = z; z = w;
return w = w ^ w >> 19 ^ t ^ t >> 8;
}
inline int next(int n) { return uint64_t(next()) * uint32_t(n) >> 32; }
inline int next(int lo, int hi) { return lo + next(hi - lo + 1); }
inline double next(double x) { return double(next()) / (1LL << 32) * x; }
inline double next(double lo, double hi) { return lo + next(hi - lo); }
};
Timer timer(1.98);
XorShift rnd;
double get_param(const char* env_var) {
char* ret = getenv(env_var);
assert (ret != nullptr);
return stod(std::string(ret));
}
#include "snippets/containers.h"
#include "snippets/grid.h"
#include "snippets/profiler.h"
#include "snippets/shortest_path.h"
#include "snippets/simulated_annealing.h"
#include "snippets/unionfind.h"
#include "snippets/beam_search.h"
using namespace std;
void SetUp() {
// Reading inputs and preprocessing
}
struct Solver {
Solver() {
// Initialization
}
int Run() {
// Implement the solution here
return 0;
}
void Output() {
// Output the answer to stdout
}
};
int main() {
SetUp();
Solver solver;
int score = solver.Run();
LOG(score);
solver.Output();
double elapsed = timer.elapsed();
LOG(elapsed);
}