-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem.h
69 lines (62 loc) · 1.47 KB
/
problem.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
#pragma once
#include <complex>
#include <vector>
#include <fstream>
#include "base/base.h"
#include "boost/multiprecision/cpp_int.hpp"
#include "boost/rational.hpp"
#include "polygon.h"
using boost::rational;
using boost::rational_cast;
using namespace std;
struct Problem {
vector<Polygon> polygons;
vector<pair<Vertex, Vertex>> skelton;
};
void ReadProblem(std::istream& is, Problem* p) {
int n_polys;
CHECK(is >> n_polys);
p->polygons.resize(n_polys);
for (int i = 0; i < n_polys; ++i) {
is >> p->polygons[i];
}
int n_edges;
CHECK(is >> n_edges);
p->skelton.resize(n_edges);
for (int i = 0; i < n_edges; ++i) {
is >> p->skelton[i].first >> p->skelton[i].second;
}
}
void WriteProblem(const Problem& p, std::ostream& os) {
os << p.polygons.size() << '\n';
for (const auto& poly : p.polygons) {
os << poly;
}
os << p.skelton.size() << '\n';
for (const auto& seg : p.skelton) {
os << seg.first << ' ' << seg.second << '\n';
}
}
struct FilteredProblem {
vector<Vertex> vertices;
vector<vector<int>> polygons;
};
void ReadFilteredProblem(std::istream& is, FilteredProblem* p) {
int n_verts;
is >> n_verts;
p->vertices.resize(n_verts);
for (int i = 0; i < n_verts; ++i) {
is >> p->vertices[i];
}
int n_polys;
is >> n_polys;
p->polygons.resize(n_polys);
for (int i = 0; i < n_polys; ++i) {
int n;
is >> n;
p->polygons[i].resize(n);
for (int j = 0; j < n; ++j) {
is >> p->polygons[i][j];
}
}
}