-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
52 lines (43 loc) · 1.28 KB
/
main.cpp
File metadata and controls
52 lines (43 loc) · 1.28 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
#include <fstream>
#include <string>
#include <vector>
#include "BMPWriter.h"
Nonogram ReadFromFile(const std::string &path) {
std::ifstream fin(path, std::ios::in);
size_t height = 0, width = 0;
fin >> height >> width;
std::vector<std::vector<int>> rows(height, std::vector<int>(0));
std::vector<std::vector<int>> cols(width, std::vector<int>(0));
for (size_t i = 0; i < width; ++i) {
size_t string_len = 0;
fin >> string_len;
for (size_t j = 0; j < string_len; ++j) {
int number;
fin >> number;
cols[i].push_back(number);
}
}
for (size_t i = 0; i < height; ++i) {
size_t string_len = 0;
fin >> string_len;
for (size_t j = 0; j < string_len; ++j) {
int number;
fin >> number;
rows[i].push_back(number);
}
}
return {Nonogram(std::move(rows), std::move(cols), width, height)};
}
int main(int argc, char *argv[]) {
std::string input_path;
std::string output_path;
if (argc > 1) {
input_path = argv[1];
output_path = argv[2];
Nonogram nonogram = ReadFromFile(input_path);
nonogram.Solve();
nonogram.Increase(8);
Write(output_path, nonogram);
}
return 0;
}