当前位置:网站首页>130. Zones environnantes
130. Zones environnantes
2022-07-08 00:59:00 【Anieoo】
Lien vers la question originale:130. Zone entourée
solution:
dfs
class Solution {
public:
void solve(vector<vector<char>>& board) {
int m = board.size(),n = board[0].size();
for(int i = 0;i < m;i++) {
dfs(board, i, 0);
dfs(board, i, n - 1);
}
for(int j = 0;j < n;j++) {
dfs(board, 0, j);
dfs(board, m - 1, j);
}
for(int i = 0;i < m;i++)
for(int j = 0;j < n;j++) {
if(board[i][j] == '#') board[i][j] = 'O';
else if(board[i][j] == 'O') board[i][j] = 'X';
}
}
// De la frontière extérieure dfs, Pour étendre chaque ODevient#,En coursm*nTraversée,Pour le resteODevientX
void dfs(vector<vector<char>> &board, int x,int y) {
if(x < 0 || x == board.size() || y < 0 || y == board[0].size() || board[x][y] != 'O') return;
board[x][y] = '#';
dfs(board, x + 1, y);
dfs(board, x, y + 1);
dfs(board, x - 1, y);
dfs(board, x, y - 1);
}
};
边栏推荐
- German prime minister says Ukraine will not receive "NATO style" security guarantee
- Basic mode of service mesh
- 9.卷积神经网络介绍
- SDNU_ ACM_ ICPC_ 2022_ Summer_ Practice(1~2)
- 【笔记】常见组合滤波电路
- 【obs】Impossible to find entrance point CreateDirect3D11DeviceFromDXGIDevice
- 新库上线 | CnOpenData中华老字号企业名录
- Hotel
- 4.交叉熵
- 2022-07-07: the original array is a monotonic array with numbers greater than 0 and less than or equal to K. there may be equal numbers in it, and the overall trend is increasing. However, the number
猜你喜欢
ThinkPHP kernel work order system source code commercial open source version multi user + multi customer service + SMS + email notification
Deep dive kotlin synergy (XXII): flow treatment
国内首次,3位清华姚班本科生斩获STOC最佳学生论文奖
9. Introduction to convolutional neural network
Jemter distributed
8道经典C语言指针笔试题解析
From starfish OS' continued deflationary consumption of SFO, the value of SFO in the long run
Prediction of the victory or defeat of the League of heroes -- simple KFC Colonel
jemter分布式
New library launched | cnopendata China Time-honored enterprise directory
随机推荐
QT adds resource files, adds icons for qaction, establishes signal slot functions, and implements
After going to ByteDance, I learned that there are so many test engineers with an annual salary of 40W?
【愚公系列】2022年7月 Go教学课程 006-自动推导类型和输入输出
Tapdata 的 2.0 版 ,开源的 Live Data Platform 现已发布
串口接收一包数据
jemter分布式
C# ?,?.,?? .....
利用GPU训练网络模型
Reentrantlock fair lock source code Chapter 0
Prediction of the victory or defeat of the League of heroes -- simple KFC Colonel
新库上线 | CnOpenData中华老字号企业名录
韦东山第二期课程内容概要
取消select的默认样式的向下箭头和设置select默认字样
QT establish signal slots between different classes and transfer parameters
Qt添加资源文件,为QAction添加图标,建立信号槽函数并实现
13. Enregistrement et chargement des modèles
10.CNN应用于手写数字识别
5g NR system messages
跨模态语义关联对齐检索-图像文本匹配(Image-Text Matching)
第四期SFO销毁,Starfish OS如何对SFO价值赋能?