1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-05 07:21:40 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/分割正方形 II [separate-squares-ii].html
2025-02-22 16:46:22 +08:00

51 lines
2.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>给你一个二维整数数组 <code>squares</code>&nbsp;,其中&nbsp;<code>squares[i] = [x<sub>i</sub>, y<sub>i</sub>, l<sub>i</sub>]</code> 表示一个与 x 轴平行的正方形的左下角坐标和正方形的边长。</p>
<p>找到一个<strong>最小的</strong> y 坐标,它对应一条水平线,该线需要满足它以上正方形的总面积 <strong>等于</strong> 该线以下正方形的总面积。</p>
<p>答案如果与实际答案的误差在 <code>10<sup>-5</sup></code> 以内,将视为正确答案。</p>
<p><strong>注意</strong>:正方形&nbsp;<strong>可能会&nbsp;</strong>重叠。重叠区域只&nbsp;<strong>统计一次&nbsp;</strong></p>
<p>&nbsp;</p>
<p><strong class="example">示例 1</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">squares = [[0,0,1],[2,2,1]]</span></p>
<p><strong>输出:</strong> <span class="example-io">1.00000</span></p>
<p><strong>解释:</strong></p>
<p><img alt="" src="https://pic.leetcode.cn/1739609602-zhNmeC-4065example1drawio.png" style="width: 269px; height: 203px;" /></p>
<p>任何在 <code>y = 1</code><code>y = 2</code> 之间的水平线都会有 1 平方单位的面积在其上方1 平方单位的面积在其下方。最小的 y 坐标是 1。</p>
</div>
<p><strong class="example">示例 2</strong></p>
<div class="example-block">
<p><strong>输入:</strong> <span class="example-io">squares = [[0,0,2],[1,1,1]]</span></p>
<p><strong>输出:</strong> <span class="example-io">1.00000</span></p>
<p><strong>解释:</strong></p>
<p><img alt="" src="https://pic.leetcode.cn/1739609605-ezeVgk-4065example2drawio.png" style="width: 269px; height: 203px;" /></p>
<p>由于蓝色正方形和红色正方形有重叠区域且重叠区域只统计一次。所以直线&nbsp;<code>y = 1</code>&nbsp;将正方形分割成两部分且面积相等。</p>
</div>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= squares.length &lt;= 5 * 10<sup>4</sup></code></li>
<li><code>squares[i] = [x<sub>i</sub>, y<sub>i</sub>, l<sub>i</sub>]</code></li>
<li><code>squares[i].length == 3</code></li>
<li><code>0 &lt;= x<sub>i</sub>, y<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
<li><code>1 &lt;= l<sub>i</sub> &lt;= 10<sup>9</sup></code></li>
<li>所有正方形的总面积不超过 <code>10<sup>15</sup></code></li>
</ul>