blob: 38ae3c35a33d6039a29db9d209904768938572b4 (
plain) (
blame)
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
|
#ifndef DESIGNER_H_06F8DE64
#define DESIGNER_H_06F8DE64
#include <cstddef>
#include <list>
#include <memory>
#include <random>
#include <string>
#include <vector>
#include "cardset.h"
#include "prefix_search.h"
struct usage {
size_t cardId;
size_t strIndex;
size_t strLen;
usage(size_t ci, size_t si, size_t sl)
: cardId(ci), strIndex(si), strLen(sl) {}
};
struct solution {
const ps_type& prefix;
std::vector<size_t> lengths;
size_t score;
};
class designer {
public:
designer(std::string text, const ps_type& titles)
: text_(std::move(text)),
titles_(titles),
solutions_(text_.length() + 1) {}
std::list<usage> generate(std::mt19937& rng) const;
private:
const solution& get(size_t i) const;
solution calculate(size_t i) const;
const std::string text_;
const ps_type& titles_;
mutable std::vector<std::unique_ptr<solution>> solutions_;
};
#endif /* end of include guard: DESIGNER_H_06F8DE64 */
|