1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-09 01:11:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>有 <code>n</code> 个花园,按从&nbsp;<code>1</code>&nbsp;到 <code>n</code> 标记。另有数组 <code>paths</code> ,其中 <code>paths[i] = [x<sub>i</sub>, y<sub>i</sub>]</code>&nbsp;描述了花园&nbsp;<code>x<sub>i</sub></code> 到花园&nbsp;<code>y<sub>i</sub></code> 的双向路径。在每个花园中,你打算种下四种花之一。</p>\n\n<p>另外,所有花园 <strong>最多</strong> 有 <strong>3</strong> 条路径可以进入或离开.</p>\n\n<p>你需要为每个花园选择一种花,使得通过路径相连的任何两个花园中的花的种类互不相同。</p>\n\n<p><em>以数组形式返回 <strong>任一</strong> 可行的方案作为答案&nbsp;<code>answer</code>,其中&nbsp;<code>answer[i]</code>&nbsp;为在第&nbsp;<code>(i+1)</code>&nbsp;个花园中种植的花的种类。花的种类用 &nbsp;1、2、3、4 表示。保证存在答案。</em></p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 3, paths = [[1,2],[2,3],[3,1]]\n<strong>输出:</strong>[1,2,3]\n<strong>解释:</strong>\n花园 1 和 2 花的种类不同。\n花园 2 和 3 花的种类不同。\n花园 3 和 1 花的种类不同。\n因此[1,2,3] 是一个满足题意的答案。其他满足题意的答案有 [1,2,4]、[1,4,2] 和 [3,2,1]\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 4, paths = [[1,2],[3,4]]\n<strong>输出:</strong>[1,2,1,2]\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>n = 4, paths = [[1,2],[2,3],[3,4],[4,1],[1,3],[2,4]]\n<strong>输出:</strong>[1,2,3,4]\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= n &lt;= 10<sup>4</sup></code></li>\n\t<li><code>0 &lt;= paths.length &lt;= 2 * 10<sup>4</sup></code></li>\n\t<li><code>paths[i].length == 2</code></li>\n\t<li><code>1 &lt;= x<sub>i</sub>, y<sub>i</sub> &lt;= n</code></li>\n\t<li><code>x<sub>i</sub> != y<sub>i</sub></code></li>\n\t<li>每个花园 <strong>最多</strong> 有 <strong>3</strong> 条路径可以进入或离开</li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 117,
"likes": 122,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"13.2K\", \"totalSubmission\": \"24.4K\", \"totalAcceptedRaw\": 13222, \"totalSubmissionRaw\": 24449, \"acRate\": \"54.1%\"}",
"stats": "{\"totalAccepted\": \"13.5K\", \"totalSubmission\": \"25K\", \"totalAcceptedRaw\": 13542, \"totalSubmissionRaw\": 24962, \"acRate\": \"54.3%\"}",
"hints": [
"Since each garden is connected to at most 3 gardens, there's always an available color for each garden. For example, if one garden is next to gardens with colors 1, 3, 4, then color #2 is available."
],