-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdata.h
73 lines (57 loc) · 1.51 KB
/
data.h
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
/*
* Data stuff that needs to be used most places
*/
#ifndef H_DATA
#define H_DATA
#include <vector>
#include <iostream>
struct Coord
{
int x = 0;
int y = 0;
Coord() { }
Coord(const int x, const int y) :x(x), y(y) { }
Coord& operator+=(const Coord& c);
Coord operator+(const Coord& c) const;
};
static const Coord default_coord(-1, -1);
// A function object (functor) for sorting points by X position
struct CoordXSort
{
inline bool operator() (const Coord& p1, const Coord& p2)
{
return p1.x < p2.x;
}
};
struct Data
{
// The approximate width of the box
int width = 0;
// The diagonal of the first used box
int diag = 0;
};
// I have never seen one with more than 5 options
enum class Answer
{
Blank = 0, A, B, C, D, E
};
// Return type for threads
struct Info
{
int thread_id = 0;
long long id = 0;
std::vector<Answer> answers;
Info() { }
Info(int t) :thread_id(t) { }
Info(int t, long long i, const std::vector<Answer>& answers)
:thread_id(t), id(i), answers(answers) { }
};
std::ostream& operator<<(std::ostream& os, const Coord& c);
std::istream& operator>>(std::istream& is, Coord& c);
bool operator==(const Coord& c1, const Coord& c2);
bool operator!=(const Coord& c1, const Coord& c2);
// Less than: Is the y value less? If the same, is the x value less?
bool operator<(const Coord& c1, const Coord& c2);
bool operator>(const Coord& c1, const Coord& c2);
std::ostream& operator<<(std::ostream& os, const Answer& c);
#endif