답안 #373818

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
373818 2021-03-05T20:25:33 Z gustason Cheap flights (LMIO18_pigus_skrydziai) C++11
100 / 100
324 ms 49260 KB
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
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};
    }
}
signed 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 12396 KB Output is correct
2 Correct 8 ms 12396 KB Output is correct
3 Correct 8 ms 12396 KB Output is correct
4 Correct 8 ms 12396 KB Output is correct
5 Correct 8 ms 12396 KB Output is correct
6 Correct 14 ms 13292 KB Output is correct
7 Correct 8 ms 12396 KB Output is correct
8 Correct 8 ms 12396 KB Output is correct
9 Correct 8 ms 12396 KB Output is correct
10 Correct 8 ms 12396 KB Output is correct
11 Correct 9 ms 12396 KB Output is correct
12 Correct 8 ms 12396 KB Output is correct
13 Correct 8 ms 12396 KB Output is correct
14 Correct 8 ms 12396 KB Output is correct
15 Correct 8 ms 12396 KB Output is correct
16 Correct 8 ms 12396 KB Output is correct
17 Correct 8 ms 12396 KB Output is correct
18 Correct 9 ms 12396 KB Output is correct
19 Correct 9 ms 12524 KB Output is correct
20 Correct 8 ms 12396 KB Output is correct
21 Correct 8 ms 12396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 12396 KB Output is correct
2 Correct 8 ms 12396 KB Output is correct
3 Correct 8 ms 12396 KB Output is correct
4 Correct 8 ms 12396 KB Output is correct
5 Correct 8 ms 12396 KB Output is correct
6 Correct 14 ms 13292 KB Output is correct
7 Correct 8 ms 12396 KB Output is correct
8 Correct 8 ms 12396 KB Output is correct
9 Correct 8 ms 12396 KB Output is correct
10 Correct 8 ms 12396 KB Output is correct
11 Correct 9 ms 12396 KB Output is correct
12 Correct 8 ms 12396 KB Output is correct
13 Correct 8 ms 12396 KB Output is correct
14 Correct 8 ms 12396 KB Output is correct
15 Correct 8 ms 12396 KB Output is correct
16 Correct 8 ms 12396 KB Output is correct
17 Correct 8 ms 12396 KB Output is correct
18 Correct 9 ms 12396 KB Output is correct
19 Correct 9 ms 12524 KB Output is correct
20 Correct 8 ms 12396 KB Output is correct
21 Correct 8 ms 12396 KB Output is correct
22 Correct 198 ms 34780 KB Output is correct
23 Correct 159 ms 28780 KB Output is correct
24 Correct 15 ms 13548 KB Output is correct
25 Correct 10 ms 12780 KB Output is correct
26 Correct 11 ms 12780 KB Output is correct
27 Correct 9 ms 12524 KB Output is correct
28 Correct 88 ms 21356 KB Output is correct
29 Correct 32 ms 16364 KB Output is correct
30 Correct 47 ms 16876 KB Output is correct
31 Correct 8 ms 12396 KB Output is correct
32 Correct 8 ms 12396 KB Output is correct
33 Correct 164 ms 32620 KB Output is correct
34 Correct 130 ms 31468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 24172 KB Output is correct
2 Correct 277 ms 30352 KB Output is correct
3 Correct 66 ms 18412 KB Output is correct
4 Correct 156 ms 24812 KB Output is correct
5 Correct 324 ms 35564 KB Output is correct
6 Correct 38 ms 16492 KB Output is correct
7 Correct 106 ms 32700 KB Output is correct
8 Correct 119 ms 28960 KB Output is correct
9 Correct 12 ms 14700 KB Output is correct
10 Correct 39 ms 16492 KB Output is correct
11 Correct 101 ms 27732 KB Output is correct
12 Correct 71 ms 20716 KB Output is correct
13 Correct 8 ms 12396 KB Output is correct
14 Correct 40 ms 17004 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 24172 KB Output is correct
2 Correct 277 ms 30352 KB Output is correct
3 Correct 66 ms 18412 KB Output is correct
4 Correct 156 ms 24812 KB Output is correct
5 Correct 324 ms 35564 KB Output is correct
6 Correct 38 ms 16492 KB Output is correct
7 Correct 106 ms 32700 KB Output is correct
8 Correct 119 ms 28960 KB Output is correct
9 Correct 12 ms 14700 KB Output is correct
10 Correct 39 ms 16492 KB Output is correct
11 Correct 101 ms 27732 KB Output is correct
12 Correct 71 ms 20716 KB Output is correct
13 Correct 8 ms 12396 KB Output is correct
14 Correct 40 ms 17004 KB Output is correct
15 Correct 8 ms 12396 KB Output is correct
16 Correct 8 ms 12396 KB Output is correct
17 Correct 8 ms 12396 KB Output is correct
18 Correct 8 ms 12396 KB Output is correct
19 Correct 8 ms 12396 KB Output is correct
20 Correct 14 ms 13292 KB Output is correct
21 Correct 8 ms 12396 KB Output is correct
22 Correct 8 ms 12396 KB Output is correct
23 Correct 8 ms 12396 KB Output is correct
24 Correct 8 ms 12396 KB Output is correct
25 Correct 9 ms 12396 KB Output is correct
26 Correct 8 ms 12396 KB Output is correct
27 Correct 8 ms 12396 KB Output is correct
28 Correct 8 ms 12396 KB Output is correct
29 Correct 8 ms 12396 KB Output is correct
30 Correct 8 ms 12396 KB Output is correct
31 Correct 8 ms 12396 KB Output is correct
32 Correct 9 ms 12396 KB Output is correct
33 Correct 9 ms 12524 KB Output is correct
34 Correct 8 ms 12396 KB Output is correct
35 Correct 8 ms 12396 KB Output is correct
36 Correct 198 ms 34780 KB Output is correct
37 Correct 159 ms 28780 KB Output is correct
38 Correct 15 ms 13548 KB Output is correct
39 Correct 10 ms 12780 KB Output is correct
40 Correct 11 ms 12780 KB Output is correct
41 Correct 9 ms 12524 KB Output is correct
42 Correct 88 ms 21356 KB Output is correct
43 Correct 32 ms 16364 KB Output is correct
44 Correct 47 ms 16876 KB Output is correct
45 Correct 8 ms 12396 KB Output is correct
46 Correct 8 ms 12396 KB Output is correct
47 Correct 164 ms 32620 KB Output is correct
48 Correct 130 ms 31468 KB Output is correct
49 Correct 144 ms 22728 KB Output is correct
50 Correct 87 ms 20560 KB Output is correct
51 Correct 115 ms 21980 KB Output is correct
52 Correct 137 ms 22720 KB Output is correct
53 Correct 64 ms 17756 KB Output is correct
54 Correct 113 ms 29036 KB Output is correct
55 Correct 312 ms 49260 KB Output is correct
56 Correct 195 ms 36972 KB Output is correct
57 Correct 177 ms 29140 KB Output is correct
58 Correct 73 ms 20936 KB Output is correct
59 Correct 192 ms 34948 KB Output is correct
60 Correct 132 ms 29092 KB Output is correct
61 Correct 107 ms 27788 KB Output is correct