-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsudoku.cpp
55 lines (51 loc) · 1.23 KB
/
sudoku.cpp
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
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;
int main() {
// Get input.
vector< pair<int, int> > clueij;
vector<string> clues;
string line;
istringstream iss;
while (getline(cin, line)) {
iss.clear();
iss.str(line);
string p;
iss >> p;
clueij.push_back(make_pair(stoi(p.substr(1,1)), stoi(p.substr(2,1))));
clues.push_back(line);
}
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
cout << "p" << i << j << " ";
cout << "b" << i << j+1 << " ";
}
}
for (int i = 0; i < 4; i++) {
for (int k = 1; k <= 4; k++) {
cout << "r" << i << k << " ";
cout << "c" << i << k << " ";
}
}
cout << endl;
for (int i = 0; i < 4; i++) {
for (int j = 0; j < 4; j++) {
vector< pair<int, int> >::iterator it = find(clueij.begin(), clueij.end(), make_pair(i, j));
if (it != clueij.end()) {
int d = distance(clueij.begin(), it);
cout << clues[d] << endl;
continue;
}
for (int k = 1; k <= 4; k++) {
cout << "p" << i << j << " ";
cout << "r" << i << k << " ";
cout << "c" << j << k << " ";
cout << "b" << (2*(i/2) + (j/2)) << k << endl;
}
}
}
}