当前位置:网站首页>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;
}
};
边栏推荐
- C # check whether the date is in the correct format
- 人群模拟
- 2020:MUTANT: A Training Paradigm for Out-of-Distribution Generalizationin Visual Question Answering
- Pat grade a 1020 tree Traversals
- A^2=E | 方程的解 | 这个方程究竟能告诉我们什么
- Servlet and JSP final review examination site sorting 42 questions and 42 answers
- Geometric distribution (a discrete distribution)
- 苹果唯一图谱架构常识
- fplan-布局
- 2022 operation of simulated examination platform for tea artist (Senior) work license question bank
猜你喜欢

promise源码-class版本【三、Promise源码】【代码详细注释/测试案例完整】

Super detailed, 20000 word detailed explanation, thoroughly understand es!

超级详细,2 万字详解,吃透 ES!
![Basic functions of promise [IV. promise source code]](/img/a0/8f28ec8951088b8e66e7079432f326.png)
Basic functions of promise [IV. promise source code]

栈溢出漏洞

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

There are two problems when Nacos calls microservices: 1 Load balancer does not contain an instance for the service 2. Connection refused

Pat grade a 1021 deep root

2021:passage retrieval for outside knowledgevisual question answering

Pat grade a 1025 pat ranking
随机推荐
TopoLVM: 基于LVM的Kubernetes本地持久化方案,容量感知,动态创建PV,轻松使用本地磁盘
Usage knowledge of mobile phones in new fields
Basic functions of promise [IV. promise source code]
Learn Tai Chi maker mqtt (IX) esp8266 subscribe to and publish mqtt messages at the same time
Pat grade a 1021 deep root
投资理财产品的钱有保障吗?会不会没有了?
学习太极创客 — MQTT 第二章(一)QoS 服务质量等级
PAT甲级 1020 Tree Traversals
Uni app's uparse rich text parsing perfectly parses rich text!
Implementation of window encryption shell
Resnet152 pepper pest image recognition 1.0
【数组】剑指 Offer II 012. 左右两边子数组的和相等 | 剑指 Offer II 013. 二维子矩阵的和
1. Project preparation and creation
发现一款 JSON 可视化工具神器,太爱了!
servlet与JSP期末复习考点梳理 42问42答
[promise I] introduction of promise and key issues of hand rolling
Promise source code class version [III. promise source code] [detailed code comments / complete test cases]
2020:MUTANT: A Training Paradigm for Out-of-Distribution Generalizationin Visual Question Answering
455. distribute biscuits [distribution questions]
2021:Beyond Question-Based Biases:Assessing Multimodal Shortcut Learning in Visual Question Answeri