2
2
comments : true
3
3
difficulty : 困难
4
4
edit_url : https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/README.md
5
+ tags :
6
+ - 深度优先搜索
7
+ - 广度优先搜索
8
+ - 图
9
+ - 拓扑排序
10
+ - 数组
5
11
---
6
12
7
13
<!-- problem:start -->
8
14
9
- # [ 3383. Minimum Runes to Add to Cast Spell 🔒] ( https://leetcode.cn/problems/minimum-runes-to-add-to-cast-spell )
15
+ # [ 3383. 施法所需最低符文数量 🔒] ( https://leetcode.cn/problems/minimum-runes-to-add-to-cast-spell )
10
16
11
17
[ English Version] ( /solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/README_EN.md )
12
18
13
19
## 题目描述
14
20
15
21
<!-- description:start -->
16
22
17
- <p >Alice has just graduated from wizard school, and wishes to cast a magic spell to celebrate. The magic spell contains certain <strong >focus points </strong > where magic needs to be concentrated, and some of these focus points contain < strong >magic crystals</ strong > which serve as the spell &# 39 ; s energy source. Focus points can be linked through < strong >directed runes</ strong >, which channel magic flow from one focus point to another. </p >
23
+ <p >Alice 刚刚从巫师学校毕业,并且希望施展一个魔法咒语来庆祝。魔法咒语包含某些需要集中魔力的焦点,其中一些焦点含有作为咒语能量源的魔法水晶。焦点可以通过 <strong >有向符文 </strong >& nbsp ; 进行连接,这些符文将魔力流从一个焦点传输到另一个焦点。 </p >
18
24
19
- <p >You are given a integer <code >n</code > denoting the < em >number</ em > of focus points and an array of integers < code >crystals</code > where <code >crystals[i]</code > indicates a focus point which holds a magic crystal. You are also given two integer arrays <code >flowFrom</code > and <code >flowTo</code >, which represent the existing <strong >directed runes </strong >. The <code >i<sup >th</sup ></code > rune allows magic to freely flow from focus point <code >flowFrom[i]</code > to focus point <code >flowTo[i]</code >. </p >
25
+ <p >给定一个整数 & nbsp ; <code >n</code >& nbsp ; 表示焦点的数量,以及一个整数数组 & nbsp ; < code >crystals</code >,其中 & nbsp ; <code >crystals[i]</code >& nbsp ; 表示有魔法水晶的焦点。同时给定两个整数数组 & nbsp ; <code >flowFrom</code > 和 & nbsp ; <code >flowTo</code >,表示存在的 <strong >有向符文 </strong >。第 & nbsp ; <code >i<sup >th</sup ></code >& nbsp ; 个符文允许魔力流从焦点 & nbsp ; <code >flowFrom[i]</code >& nbsp ; 传输到焦点 & nbsp ; <code >flowTo[i]</code >。 </p >
20
26
21
- <p >You need to find the number of directed runes Alice must add to her spell, such that < em >each</ em > focus point either: </p >
27
+ <p >你需要找到 Alice 必须添加到她的咒语中的定向符文数量,使得每个焦点要么: </p >
22
28
23
29
<ul >
24
- <li><strong>Contains </strong> a magic crystal. </li>
25
- <li><strong>Receives </strong> magic flow <em>from</em> another focus point. </li>
30
+ <li><strong>包含 </strong> 一个魔法水晶。 </li>
31
+ <li>从其它焦点 <strong>接收 </strong> 魔力流。 </li>
26
32
</ul >
27
33
28
- <p >Return the <strong >minimum </strong > number of directed runes that she should add. </p >
34
+ <p >返回她所需要添加的 <strong >最少 </strong >& nbsp ; 有向符文数量。 </p >
29
35
30
36
<p >  ; </p >
31
- <p ><strong class =" example " >Example 1:</strong ></p >
37
+
38
+ <p ><strong class =" example " >示例 1:</strong ></p >
32
39
33
40
<div class =" example-block " >
34
- <p ><strong >Input: </strong > <span class =" example-io " >n = 6, crystals = [0], flowFrom = [0,1,2,3], flowTo = [1,2,3,0]</span ></p >
41
+ <p ><strong >输入: </strong ><span class =" example-io " >n = 6, crystals = [0], flowFrom = [0,1,2,3], flowTo = [1,2,3,0]</span ></p >
35
42
36
- <p ><strong >Output:</ strong > < span class =" example-io " >2</span ></p >
43
+ <p ><span class =" example-io " >< b >输出:</ b >2</span ></p >
37
44
38
- <p ><strong >Explanation:</ strong > & nbsp ; </p >
45
+ <p ><b >解释:</ b > </p >
39
46
40
47
<p ><img alt =" " src =" https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/images/runesexample0.png " style =" width : 250px ; height : 252px ;" /></p >
41
48
42
- <p >Add two directed runes: </p >
49
+ <p >添加两个有向符文: </p >
43
50
44
51
<ul >
45
- <li>From focus point 0 to focus point 4. </li>
46
- <li>From focus point 0 to focus point 5. </li>
52
+ <li>从焦点 0 到焦点 4。 </li>
53
+ <li>从焦点 0 到焦点 5。 </li>
47
54
</ul >
48
55
</div >
49
56
50
- <p ><strong class =" example " >Example 2: </strong ></p >
57
+ <p ><strong class =" example " >示例 2: </strong ></p >
51
58
52
59
<div class =" example-block " >
53
- <p ><strong >Input:</ strong > < span class =" example-io " >n = 7, crystals = [3,5], flowFrom = [0,1,2,3,5], flowTo = [1,2,0,4,6]</span ></p >
60
+ <p ><span class =" example-io " >< b >输入:</ b >n = 7, crystals = [3,5], flowFrom = [0,1,2,3,5], flowTo = [1,2,0,4,6]</span ></p >
54
61
55
- <p ><strong >Output:</ strong > < span class =" example-io " >1</span ></p >
62
+ <p ><span class =" example-io " >< b >输出:</ b >1</span ></p >
56
63
57
- <p ><strong >Explanation:</ strong > & nbsp ; </p >
64
+ <p ><b >解释:</ b > </p >
58
65
59
66
<p ><img alt =" " src =" https://fastly.jsdelivr.net/gh/doocs/leetcode@main/solution/3300-3399/3383.Minimum%20Runes%20to%20Add%20to%20Cast%20Spell/images/runesexample1.png " style =" width : 250px ; height : 250px ;" /></p >
60
67
61
- <p >Add a directed rune from focus point 4 to focus point 2. </p >
68
+ <p >添加从焦点 4 到焦点 2 的有向符文。 </p >
62
69
</div >
63
70
64
71
<p >  ; </p >
65
- <p ><strong >Constraints:</strong ></p >
72
+
73
+ <p ><strong >提示:</strong ></p >
66
74
67
75
<ul >
68
76
<li><code>2 <= n <= 10<sup>5</sup></code></li>
@@ -71,7 +79,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3300-3399/3383.Mi
71
79
<li><code>1 <= flowFrom.length == flowTo.length <= min(2 * 10<sup>5</sup>, (n * (n - 1)) / 2)</code></li>
72
80
<li><code>0 <= flowFrom[i], flowTo[i] <= n - 1</code></li>
73
81
<li><code>flowFrom[i] != flowTo[i]</code></li>
74
- <li>All pre-existing directed runes are <strong>distinct </strong>. </li>
82
+ <li>所有的有向符文 <strong>互不相同 </strong>。 </li>
75
83
</ul >
76
84
77
85
<!-- description:end -->
0 commit comments