55
66using namespace std ;
77
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 << " " ; }
1311 os << endl;
1412 }
1513 return os;
1614}
1715
1816class 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) {
2119 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' ; }
2521 const int L = (n * m - broken.size ()) / 2 ;
2622 int res = 0 ;
2723 stack<tuple<char , int , int >> opr_stk;
@@ -51,12 +47,10 @@ class Solution {
5147 // 回退
5248 if (row >= n) {
5349 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; }
5751 for (;;) {
5852 if (opr_stk.empty ()) return res;
59- auto & [dir, x, y] = opr_stk.top ();
53+ auto & [dir, x, y] = opr_stk.top ();
6054 if (dir == ' -' ) {
6155 board[x][y + 1 ] = 0 ;
6256 if (x + 1 < n && board[x + 1 ][y] == 0 ) {
@@ -82,7 +76,7 @@ class Solution {
8276 }
8377};
8478
85- int main (int argc, char const * argv[]) {
79+ int main (int argc, char const * argv[]) {
8680 Solution solution;
8781
8882 // cout << solution.domino(2, 3, {{1, 0}, {1, 1}}) << endl;
0 commit comments