#include <leetcode.h>
◆ wallsAndGates()
void leetcode::walls_and_gates::Solution::wallsAndGates |
( |
vector< vector< int > > & |
rooms | ) |
|
|
static |
在文件 leetcode.cpp 第 7870 行定义.
7871 const int m = rooms.size();
7872 const int n = rooms[0].size();
7873 queue<tuple<int, int, int>> q;
7874 for(
int i = 0; i < m; i++) {
7875 for(
int j = 0; j < n; j++) {
7876 if(rooms[i][j] == 0) {
7882 auto [d, x, y] = q.front();
7884 pair<int, int> nexts[4] = {{x + 1, y}, {x - 1, y}, {x, y + 1}, {x, y - 1}};
7885 for(
auto &[next_x, next_y]: nexts) {
7886 if(next_x >= 0 && next_y >= 0 && next_x < m && next_y < n && rooms[next_x][next_y] != -1 && rooms[next_x][next_y] != 0 && (rooms[next_x][next_y] == INT_MAX || rooms[next_x][next_y] > d + 1)) {
7887 rooms[next_x][next_y] = d + 1;
7888 q.push({d + 1, next_x, next_y});
被这些函数引用 leetcode::walls_and_gates::TEST().
该类的文档由以下文件生成: