大風起兮 雲飛揚
安得猛士兮 走四方
原本想說八皇后
看一下 m, n <= 10e5
讓阿瓜走四方好像不太好
一隻阿瓜m+n
放滿mn(m+n) 不太對
直接陣列四個方向掃過去惹
class Solution {
public:
int countUnguarded(int m, int n, vector<vector<int>>& guards, vector<vector<int>>& walls) {
//empty: 0, gaurd: 1, wall: 2, see: -1
vector<vector<int>> mat(m, vector<int>(n, 0));
for(auto& g: guards){
mat[g[0]][g[1]] = 1;
}
for(auto& w: walls){
mat[w[0]][w[1]] = 2;
}
//m row, n col
//see right
for(int i = 0; i < m; i++){
int see = 0;
for(int j = 0; j < n; j++){
if(mat[i][j] == 0) mat[i][j] = see;
else if(mat[i][j] == 1) see = -1;
else if(mat[i][j] == 2) see = 0;
}
}
//see left
for(int i = 0; i < m; i++){
int see = 0;
for(int j = n-1; j >= 0; j