#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int maxN = 3e5 + 5;
struct Pii {
int a, w;
};
vector<Pii> adj[maxN];
vector<char> col(maxN);
vector<Pii> par(maxN);
ll sum[maxN], mx = 0;
void dfs(int v, int p) {
col[v] = 1;
for(auto u : adj[v]) {
if (p == u.a) continue;
if (col[u.a] == 0) {
dfs(u.a, v);
} else if (col[u.a] == 1) {
if (par[par[u.a].a].a == v) {
ll w = par[par[u.a].a].w + par[u.a].w + u.w;
mx = max(mx, w);
}
}
par[u.a] = {v, u.w};
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m;
cin >> n >> m;
for(int i = 0; i < m; i++) {
int a, b, w;
cin >> a >> b >> w;
adj[a].push_back({b, w});
adj[b].push_back({a, w});
sum[a] += w;
sum[b] += w;
}
for(int i = 1; i <= n; i++) {
if (col[i] == 0)
dfs(i, -1);
}
for(int i = 1; i <= n; i++) {
mx = max(mx, sum[i]);
}
cout << mx << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9964 KB |
Output is correct |
2 |
Correct |
8 ms |
9964 KB |
Output is correct |
3 |
Correct |
7 ms |
9964 KB |
Output is correct |
4 |
Correct |
7 ms |
9964 KB |
Output is correct |
5 |
Correct |
7 ms |
9964 KB |
Output is correct |
6 |
Correct |
13 ms |
10476 KB |
Output is correct |
7 |
Correct |
7 ms |
9964 KB |
Output is correct |
8 |
Correct |
7 ms |
9964 KB |
Output is correct |
9 |
Correct |
7 ms |
9964 KB |
Output is correct |
10 |
Correct |
8 ms |
9964 KB |
Output is correct |
11 |
Correct |
8 ms |
10092 KB |
Output is correct |
12 |
Correct |
8 ms |
10092 KB |
Output is correct |
13 |
Correct |
7 ms |
9964 KB |
Output is correct |
14 |
Correct |
7 ms |
9964 KB |
Output is correct |
15 |
Correct |
9 ms |
9964 KB |
Output is correct |
16 |
Correct |
8 ms |
9964 KB |
Output is correct |
17 |
Correct |
8 ms |
9964 KB |
Output is correct |
18 |
Correct |
9 ms |
10092 KB |
Output is correct |
19 |
Correct |
9 ms |
10092 KB |
Output is correct |
20 |
Correct |
8 ms |
9964 KB |
Output is correct |
21 |
Correct |
8 ms |
9964 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
9964 KB |
Output is correct |
2 |
Correct |
8 ms |
9964 KB |
Output is correct |
3 |
Correct |
7 ms |
9964 KB |
Output is correct |
4 |
Correct |
7 ms |
9964 KB |
Output is correct |
5 |
Correct |
7 ms |
9964 KB |
Output is correct |
6 |
Correct |
13 ms |
10476 KB |
Output is correct |
7 |
Correct |
7 ms |
9964 KB |
Output is correct |
8 |
Correct |
7 ms |
9964 KB |
Output is correct |
9 |
Correct |
7 ms |
9964 KB |
Output is correct |
10 |
Correct |
8 ms |
9964 KB |
Output is correct |
11 |
Correct |
8 ms |
10092 KB |
Output is correct |
12 |
Correct |
8 ms |
10092 KB |
Output is correct |
13 |
Correct |
7 ms |
9964 KB |
Output is correct |
14 |
Correct |
7 ms |
9964 KB |
Output is correct |
15 |
Correct |
9 ms |
9964 KB |
Output is correct |
16 |
Correct |
8 ms |
9964 KB |
Output is correct |
17 |
Correct |
8 ms |
9964 KB |
Output is correct |
18 |
Correct |
9 ms |
10092 KB |
Output is correct |
19 |
Correct |
9 ms |
10092 KB |
Output is correct |
20 |
Correct |
8 ms |
9964 KB |
Output is correct |
21 |
Correct |
8 ms |
9964 KB |
Output is correct |
22 |
Correct |
224 ms |
21484 KB |
Output is correct |
23 |
Correct |
192 ms |
26860 KB |
Output is correct |
24 |
Correct |
14 ms |
10988 KB |
Output is correct |
25 |
Correct |
11 ms |
10348 KB |
Output is correct |
26 |
Correct |
83 ms |
10348 KB |
Output is correct |
27 |
Correct |
98 ms |
10216 KB |
Output is correct |
28 |
Correct |
82 ms |
14600 KB |
Output is correct |
29 |
Correct |
37 ms |
13036 KB |
Output is correct |
30 |
Correct |
46 ms |
13164 KB |
Output is correct |
31 |
Correct |
7 ms |
10092 KB |
Output is correct |
32 |
Correct |
7 ms |
10092 KB |
Output is correct |
33 |
Correct |
163 ms |
20240 KB |
Output is correct |
34 |
Correct |
128 ms |
19620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
137 ms |
22556 KB |
Output is correct |
2 |
Correct |
306 ms |
25864 KB |
Output is correct |
3 |
Correct |
70 ms |
13988 KB |
Output is correct |
4 |
Correct |
172 ms |
21484 KB |
Output is correct |
5 |
Correct |
308 ms |
31724 KB |
Output is correct |
6 |
Correct |
38 ms |
13292 KB |
Output is correct |
7 |
Correct |
110 ms |
30188 KB |
Output is correct |
8 |
Correct |
125 ms |
21728 KB |
Output is correct |
9 |
Correct |
11 ms |
12396 KB |
Output is correct |
10 |
Correct |
38 ms |
12140 KB |
Output is correct |
11 |
Correct |
93 ms |
20100 KB |
Output is correct |
12 |
Correct |
69 ms |
16620 KB |
Output is correct |
13 |
Correct |
7 ms |
9964 KB |
Output is correct |
14 |
Correct |
40 ms |
12396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
137 ms |
22556 KB |
Output is correct |
2 |
Correct |
306 ms |
25864 KB |
Output is correct |
3 |
Correct |
70 ms |
13988 KB |
Output is correct |
4 |
Correct |
172 ms |
21484 KB |
Output is correct |
5 |
Correct |
308 ms |
31724 KB |
Output is correct |
6 |
Correct |
38 ms |
13292 KB |
Output is correct |
7 |
Correct |
110 ms |
30188 KB |
Output is correct |
8 |
Correct |
125 ms |
21728 KB |
Output is correct |
9 |
Correct |
11 ms |
12396 KB |
Output is correct |
10 |
Correct |
38 ms |
12140 KB |
Output is correct |
11 |
Correct |
93 ms |
20100 KB |
Output is correct |
12 |
Correct |
69 ms |
16620 KB |
Output is correct |
13 |
Correct |
7 ms |
9964 KB |
Output is correct |
14 |
Correct |
40 ms |
12396 KB |
Output is correct |
15 |
Correct |
7 ms |
9964 KB |
Output is correct |
16 |
Correct |
8 ms |
9964 KB |
Output is correct |
17 |
Correct |
7 ms |
9964 KB |
Output is correct |
18 |
Correct |
7 ms |
9964 KB |
Output is correct |
19 |
Correct |
7 ms |
9964 KB |
Output is correct |
20 |
Correct |
13 ms |
10476 KB |
Output is correct |
21 |
Correct |
7 ms |
9964 KB |
Output is correct |
22 |
Correct |
7 ms |
9964 KB |
Output is correct |
23 |
Correct |
7 ms |
9964 KB |
Output is correct |
24 |
Correct |
8 ms |
9964 KB |
Output is correct |
25 |
Correct |
8 ms |
10092 KB |
Output is correct |
26 |
Correct |
8 ms |
10092 KB |
Output is correct |
27 |
Correct |
7 ms |
9964 KB |
Output is correct |
28 |
Correct |
7 ms |
9964 KB |
Output is correct |
29 |
Correct |
9 ms |
9964 KB |
Output is correct |
30 |
Correct |
8 ms |
9964 KB |
Output is correct |
31 |
Correct |
8 ms |
9964 KB |
Output is correct |
32 |
Correct |
9 ms |
10092 KB |
Output is correct |
33 |
Correct |
9 ms |
10092 KB |
Output is correct |
34 |
Correct |
8 ms |
9964 KB |
Output is correct |
35 |
Correct |
8 ms |
9964 KB |
Output is correct |
36 |
Correct |
224 ms |
21484 KB |
Output is correct |
37 |
Correct |
192 ms |
26860 KB |
Output is correct |
38 |
Correct |
14 ms |
10988 KB |
Output is correct |
39 |
Correct |
11 ms |
10348 KB |
Output is correct |
40 |
Correct |
83 ms |
10348 KB |
Output is correct |
41 |
Correct |
98 ms |
10216 KB |
Output is correct |
42 |
Correct |
82 ms |
14600 KB |
Output is correct |
43 |
Correct |
37 ms |
13036 KB |
Output is correct |
44 |
Correct |
46 ms |
13164 KB |
Output is correct |
45 |
Correct |
7 ms |
10092 KB |
Output is correct |
46 |
Correct |
7 ms |
10092 KB |
Output is correct |
47 |
Correct |
163 ms |
20240 KB |
Output is correct |
48 |
Correct |
128 ms |
19620 KB |
Output is correct |
49 |
Correct |
118 ms |
18752 KB |
Output is correct |
50 |
Correct |
87 ms |
18156 KB |
Output is correct |
51 |
Correct |
115 ms |
19716 KB |
Output is correct |
52 |
Correct |
128 ms |
16016 KB |
Output is correct |
53 |
Correct |
63 ms |
16608 KB |
Output is correct |
54 |
Correct |
114 ms |
22892 KB |
Output is correct |
55 |
Correct |
320 ms |
46700 KB |
Output is correct |
56 |
Correct |
221 ms |
30316 KB |
Output is correct |
57 |
Incorrect |
198 ms |
28508 KB |
Output isn't correct |
58 |
Halted |
0 ms |
0 KB |
- |