当前位置:网站首页>733. image rendering
733. image rendering
2022-06-27 03:32:00 【Blueberry man】
It can be understood as width traversal of graph
If the colors are the same, exit directly to prevent infinite recursion
class Solution {
public:
class pos
{
public:
int x_;
int y_;
pos(int x, int y):x_(x),y_(y){}
};
vector<vector<int>> floodFill(vector<vector<int>>& image, int sr, int sc, int color) {
if(image.empty())
return image;
int standard_color = image.at(sr).at(sc);
if(color == standard_color)
return image;
queue<pos>to_use;
to_use.push(pos(sr,sc));
image.at(sr).at(sc) = color;
while(!to_use.empty())
{
auto cur_pos = to_use.front();
to_use.pop();
if(cur_pos.x_-1 >=0 && image.at(cur_pos.x_-1).at(cur_pos.y_)==standard_color)
{
image.at(cur_pos.x_-1).at(cur_pos.y_) = color;
to_use.push(pos(cur_pos.x_-1, cur_pos.y_));
}
if(cur_pos.x_+1 <(int)image.size() && image.at(cur_pos.x_+1).at(cur_pos.y_)==standard_color)
{
image.at(cur_pos.x_+1).at(cur_pos.y_) = color;
to_use.push(pos(cur_pos.x_+1, cur_pos.y_));
}
if(cur_pos.y_-1 >=0 && image.at(cur_pos.x_).at(cur_pos.y_-1)==standard_color)
{
image.at(cur_pos.x_).at(cur_pos.y_-1) = color;
to_use.push(pos(cur_pos.x_, cur_pos.y_-1));
}
if(cur_pos.y_+1<(int)image[0].size() && image.at(cur_pos.x_).at(cur_pos.y_+1)==standard_color)
{
image.at(cur_pos.x_).at(cur_pos.y_+1) = color;
to_use.push(pos(cur_pos.x_, cur_pos.y_+1));
}
}
return image;
}
};
边栏推荐
- 【数组】剑指 Offer II 012. 左右两边子数组的和相等 | 剑指 Offer II 013. 二维子矩阵的和
- 学习太极创客 — MQTT(七)MQTT 主题进阶
- PAT甲级 1026 Table Tennis
- pytorch_ grad_ Cam -- visual Library of class activation mapping (CAM) under pytorch
- resnet152 辣椒病虫害图像识别1.0
- 学习太极创客 — MQTT(九)ESP8266 同时订阅和发布 MQTT 消息
- 455. distribute biscuits [distribution questions]
- 我是怎样简化开源系统中的接口的开发的?
- Window 加密壳实现
- 2021:Beyond Question-Based Biases:Assessing Multimodal Shortcut Learning in Visual Question Answeri
猜你喜欢

2021:Graphhopper: Multi-Hop Scene Graph Reasoning for Visual Question Answering

Pat grade a 1025 pat ranking

Learning Tai Chi Maker - mqtt Chapter 2 (II) esp8266 QoS application

Anaconda3安裝過程及安裝後缺失大量文件,沒有scripts等目錄

2021:Check it again:Progressive Visual Question Answering via Visual Entailment通过视觉暗示进行渐进式视觉问答

Record the method of reading excel provided by unity and the solution to some pits encountered

pytorch_ grad_ Cam -- visual Library of class activation mapping (CAM) under pytorch

GAMES101作业7提高-微表面材质的实现过程

fplan-Powerplan实例

Uni app's uparse rich text parsing perfectly parses rich text!
随机推荐
Learning Tai Chi Maker - mqtt (VII) advanced mqtt theme
卷积神经网络(CNN)网络结构及模型原理介绍
How does source insight (SI) display the full path? (do not display omitted paths) (turn off trim long path names with ellipses)
Anaconda3安裝過程及安裝後缺失大量文件,沒有scripts等目錄
2021:Greedy Gradient Ensemble for Robust Visual Question Answering
Learn Tai Chi Maker - mqtt (VI) esp8266 releases mqtt message
2021:Check it again:Progressive Visual Question Answering via Visual Entailment通过视觉暗示进行渐进式视觉问答
TechSmith Camtasia latest 2022 detailed function explanation Download
Quicksand painting simulator source code
PAT甲级 1019 General Palindromic Number
Promise source code class version [III. promise source code] [detailed code comments / complete test cases]
PAT甲级 1024 Palindromic Number
2019LXMERT:Learning Cross-Modality Encoder Representations from Transformers
实践 DevOps 时,可能面临的六大挑战
超級詳細,2 萬字詳解,吃透 ES!
Paddlepaddle 21 is implemented based on dropout with 4 lines of code droplock
Pat grade a 1021 deep root
Pat class a 1024 palindromic number
发现一款 JSON 可视化工具神器,太爱了!
事业观、金钱观与幸福观