5
5
6
6
using namespace std ;
7
7
8
- ostream& operator <<(ostream& os, const std::vector<vector<char >>& board) {
9
- for (auto && row : board) {
10
- for (auto && col : row) {
11
- os << col << " " ;
12
- }
8
+ ostream &operator <<(ostream &os, const std::vector<vector<char >> &board) {
9
+ for (auto &&row : board) {
10
+ for (auto &&col : row) { os << col << " " ; }
13
11
os << endl;
14
12
}
15
13
return os;
16
14
}
17
15
18
16
class Solution {
19
- public:
20
- int domino (int n, int m, const vector<vector<int >>& broken) {
17
+ public:
18
+ int domino (int n, int m, const vector<vector<int >> & broken) {
21
19
vector<vector<char >> board (n, vector<char >(m, 0 ));
22
- for (auto && xy : broken) {
23
- board[xy[0 ]][xy[1 ]] = ' X' ;
24
- }
20
+ for (auto &&xy : broken) { board[xy[0 ]][xy[1 ]] = ' X' ; }
25
21
const int L = (n * m - broken.size ()) / 2 ;
26
22
int res = 0 ;
27
23
stack<tuple<char , int , int >> opr_stk;
@@ -51,12 +47,10 @@ class Solution {
51
47
// 回退
52
48
if (row >= n) {
53
49
res = std::max<int >(res, opr_stk.size ());
54
- if (opr_stk.size () == L) {
55
- return L;
56
- }
50
+ if (opr_stk.size () == L) { return L; }
57
51
for (;;) {
58
52
if (opr_stk.empty ()) return res;
59
- auto & [dir, x, y] = opr_stk.top ();
53
+ auto & [dir, x, y] = opr_stk.top ();
60
54
if (dir == ' -' ) {
61
55
board[x][y + 1 ] = 0 ;
62
56
if (x + 1 < n && board[x + 1 ][y] == 0 ) {
@@ -82,7 +76,7 @@ class Solution {
82
76
}
83
77
};
84
78
85
- int main (int argc, char const * argv[]) {
79
+ int main (int argc, char const * argv[]) {
86
80
Solution solution;
87
81
88
82
// cout << solution.domino(2, 3, {{1, 0}, {1, 1}}) << endl;
0 commit comments