Skip to content

Commit c094f19

Browse files
committed
0924 codes updated.
1 parent d532172 commit c094f19

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

0924-Minimize-Malware-Spread/cpp-0924/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class Solution {
3232
visited.resize(n, false);
3333

3434
int best = 0, res = -1, ccid = 0;
35-
for(int v = 0; v < n; v ++)
36-
if(init_set.count(v) && !visited[v]){
35+
for(int v: init_set)
36+
if(!visited[v]){
3737
cc_sz.push_back(0), cc_mal_num.push_back(0);
3838
cc_sz[ccid] = dfs(graph, v, ccid);
3939
if(cc_mal_num[ccid] == 1 && cc_sz[ccid] > best){
@@ -50,6 +50,7 @@ class Solution {
5050

5151
visited[v] = true;
5252
if(init_set.count(v)) cc_mal_num[ccid] ++;
53+
5354
int res = 1;
5455
for(int next = 0; next < n; next ++)
5556
if(g[v][next] && !visited[next])

0924-Minimize-Malware-Spread/cpp-0924/main2.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ class Solution {
6767
if(graph[i][j])
6868
uf.unionElements(i, j);
6969

70-
set<int> init_set;
71-
for(int e: initial) init_set.insert(e);
70+
set<int> init_set(initial.begin(), initial.end());
7271

7372
unordered_map<int, int> cc_sz, cc_mal_num;
7473
for(int e: init_set)

0 commit comments

Comments
 (0)