Submission #373815

# Submission time Handle Problem Language Result Execution time Memory
373815 2021-03-05T20:24:22 Z gustason Cheap flights (LMIO18_pigus_skrydziai) C++11
53 / 100
331 ms 41756 KB
#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 10676 KB Output is correct
7 Correct 8 ms 9976 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 10240 KB Output is correct
13 Correct 7 ms 10092 KB Output is correct
14 Correct 8 ms 9964 KB Output is correct
15 Correct 7 ms 9964 KB Output is correct
16 Correct 7 ms 9964 KB Output is correct
17 Correct 8 ms 9964 KB Output is correct
18 Correct 8 ms 10092 KB Output is correct
19 Correct 8 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 10676 KB Output is correct
7 Correct 8 ms 9976 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 10240 KB Output is correct
13 Correct 7 ms 10092 KB Output is correct
14 Correct 8 ms 9964 KB Output is correct
15 Correct 7 ms 9964 KB Output is correct
16 Correct 7 ms 9964 KB Output is correct
17 Correct 8 ms 9964 KB Output is correct
18 Correct 8 ms 10092 KB Output is correct
19 Correct 8 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 213 ms 30188 KB Output is correct
23 Correct 187 ms 18296 KB Output is correct
24 Correct 14 ms 10604 KB Output is correct
25 Correct 9 ms 10220 KB Output is correct
26 Correct 52 ms 10220 KB Output is correct
27 Correct 94 ms 10168 KB Output is correct
28 Correct 75 ms 18028 KB Output is correct
29 Correct 30 ms 11884 KB Output is correct
30 Correct 67 ms 13932 KB Output is correct
31 Correct 7 ms 10092 KB Output is correct
32 Correct 7 ms 10092 KB Output is correct
33 Correct 174 ms 28396 KB Output is correct
34 Correct 130 ms 24812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 23404 KB Output is correct
2 Correct 271 ms 22360 KB Output is correct
3 Correct 74 ms 15340 KB Output is correct
4 Correct 163 ms 18696 KB Output is correct
5 Correct 324 ms 27372 KB Output is correct
6 Correct 37 ms 12140 KB Output is correct
7 Correct 107 ms 26348 KB Output is correct
8 Correct 119 ms 26256 KB Output is correct
9 Correct 11 ms 12396 KB Output is correct
10 Correct 45 ms 13420 KB Output is correct
11 Correct 98 ms 23132 KB Output is correct
12 Correct 72 ms 14188 KB Output is correct
13 Correct 7 ms 9964 KB Output is correct
14 Correct 38 ms 13548 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 150 ms 23404 KB Output is correct
2 Correct 271 ms 22360 KB Output is correct
3 Correct 74 ms 15340 KB Output is correct
4 Correct 163 ms 18696 KB Output is correct
5 Correct 324 ms 27372 KB Output is correct
6 Correct 37 ms 12140 KB Output is correct
7 Correct 107 ms 26348 KB Output is correct
8 Correct 119 ms 26256 KB Output is correct
9 Correct 11 ms 12396 KB Output is correct
10 Correct 45 ms 13420 KB Output is correct
11 Correct 98 ms 23132 KB Output is correct
12 Correct 72 ms 14188 KB Output is correct
13 Correct 7 ms 9964 KB Output is correct
14 Correct 38 ms 13548 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 10676 KB Output is correct
21 Correct 8 ms 9976 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 10240 KB Output is correct
27 Correct 7 ms 10092 KB Output is correct
28 Correct 8 ms 9964 KB Output is correct
29 Correct 7 ms 9964 KB Output is correct
30 Correct 7 ms 9964 KB Output is correct
31 Correct 8 ms 9964 KB Output is correct
32 Correct 8 ms 10092 KB Output is correct
33 Correct 8 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 213 ms 30188 KB Output is correct
37 Correct 187 ms 18296 KB Output is correct
38 Correct 14 ms 10604 KB Output is correct
39 Correct 9 ms 10220 KB Output is correct
40 Correct 52 ms 10220 KB Output is correct
41 Correct 94 ms 10168 KB Output is correct
42 Correct 75 ms 18028 KB Output is correct
43 Correct 30 ms 11884 KB Output is correct
44 Correct 67 ms 13932 KB Output is correct
45 Correct 7 ms 10092 KB Output is correct
46 Correct 7 ms 10092 KB Output is correct
47 Correct 174 ms 28396 KB Output is correct
48 Correct 130 ms 24812 KB Output is correct
49 Correct 111 ms 16212 KB Output is correct
50 Correct 108 ms 14400 KB Output is correct
51 Correct 111 ms 18016 KB Output is correct
52 Correct 133 ms 20688 KB Output is correct
53 Correct 61 ms 14688 KB Output is correct
54 Correct 112 ms 21228 KB Output is correct
55 Correct 331 ms 41756 KB Output is correct
56 Correct 220 ms 34796 KB Output is correct
57 Incorrect 195 ms 24928 KB Output isn't correct
58 Halted 0 ms 0 KB -