当前位置:网站首页>9196 tumor area solution
9196 tumor area solution
2022-07-29 06:24:00 【C2024XSC249】
Link Click to see the original question
Tumor area
2021.8.14 Regular practice of two-dimensional array 2 A topic
This problem is a relatively simple two-dimensional array problem :
First step : Input picture
We define an array a a a And quantity n n n, And enter the :
int a[MAXN][MAXN], n;
And then use f o r for for Nesting the input array circularly .
The second step : Find the coordinates of the upper left corner and the lower right corner
Definition
Because the tumor is a rectangle , So we can use coordinates to get the area .
Definition 4 A variable , Represents the upper left corner and the lower right corner x 、 y x、y x、y value
int zs_x = 0, zs_y, yx_x, yx_y
notes : Turn the upper left corner x Coordinate self 0, Whether the mark has been recorded .
lookup
use f o r for for Loop through the entire array , If the point is 0:
1. if z s x zs_x zsx by 0( Not found before ): Mark the coordinates of the upper left corner
2. Not for 0: skip
Mark the coordinates of the lower right corner .
The judging code is as follows :
if (zs_x == 0 && a[i][j] == 0) {
zs_x = i, zs_y = j;
}
if (a[i][j] == 0) {
yx_x = i, yx_y = j;
}
The third step : Calculated area
int ans = (yx_x - zs_x - 1) * (yx_y - zs_y - 1);
Just output .
And finally
Want full code ? No way
And finally : Plagiarism is useless
Thank you for watching.
边栏推荐
- 2022 spring recruit - Hesai technology FPGA technology post (one or two sides, collected from: Digital IC workers and FPGA Explorers)
- LeetCode #167.两数之和 II - 输入有序数组
- Leetcode 13. Roman numeral to integer
- scanBasePackages扫包范围配置
- ML10 self study notes SVM
- 官方教程 Redshift 05 AOVs
- Shell tool finalshell
- 官方教程 Redshift 07 Instances and Proxy
- JUC collection class is unsafe
- STM32: mcnamu wheel tracking task (library function program code)
猜你喜欢
![[beauty of software engineering - column notes] 17 | what is the need analysis? How to analyze?](/img/54/5ea29b125e3b871cd08d52ccc05d3a.png)
[beauty of software engineering - column notes] 17 | what is the need analysis? How to analyze?

ML7 self study notes

Pit avoidance: about the interconnection of two hc-05 master-slave integrated Bluetooth modules, there is no connection problem

【软件工程之美 - 专栏笔记】29 | 自动化测试:如何把Bug杀死在摇篮里?

Leetcode 344. reverse string

传统模型预测控制轨迹跟踪——圆形轨迹(功能包已经更新)

【软件工程之美 - 专栏笔记】28 | 软件工程师的核心竞争力是什么?(下)

关于时间复杂度的个人看法

Leetcode 557. reverse word III in string

Add time series index to two-dimensional table
随机推荐
太原市公交路线爬取
Leetcode 167. sum of two numbers II - input ordered array
MySql-面试题
Computer factory interview questions
Install MySQL from scratch (MySQL installation document - unzipped version)
【软件工程之美 - 专栏笔记】25 | 有哪些方法可以提高开发效率?
Leetcode 344. reverse string
Linked list -------------------------- tail insertion method
抽象类以及接口
【软件工程之美 - 专栏笔记】13 | 白天开会,加班写代码的节奏怎么破?
【Leetcode刷题】数组1——双指针
Abstract encapsulation inheritance polymorphism
Leetcode 876. Intermediate node of linked list
LeetCode #35.搜索插入位置
synchronized八锁现象理解
shell工具finalShell
Traditional model predictive control trajectory tracking - circular trajectory (function package has been updated)
NOI Online 2022普及组 题解&个人领悟
leetcode刷题笔记 605. Can Place Flowers (Easy) 605.种花问题
LeetCode #7.整数反转