답안 #924221

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
924221 2024-02-08T16:35:23 Z dwuy Cheap flights (LMIO18_pigus_skrydziai) C++14
53 / 100
615 ms 44884 KB
#include <bits/stdc++.h>

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL)
#define file(a) freopen(a".inp","r",stdin); freopen(a".out", "w",stdout)
#define fi first
#define se second
#define endl "\n"
#define len(s) int32_t(s.length())
#define MASK(k)(1LL<<(k))
#define TASK "test"
#define int long long

using namespace std;

typedef tuple<int, int, int> tpiii;
typedef pair<double, double> pdd;
typedef pair<int, int> pii;
typedef long long ll;

const long long OO = 1e18;
const int MOD = 1e9 + 7;
const int INF = 1e9;
const int MX = 300005;

int n, m;
int sum[MX];
vector<pii> G[MX];
tpiii edges[MX<<1];
bitset<MX> ok = 0;
int cost[MX];

void nhap(){
    cin >> n >> m;
    for(int i=1; i<=m; i++){
        int u, v, c;
        cin >> u >> v >> c;
        G[u].push_back({v, c});
        G[v].push_back({u, c});
        edges[i] = {c, u, v};
        sum[u] += c;
        sum[v] += c;
    }
}

void solve(){
    int ans = 0;
    for(int i=1; i<=n; i++) ans = max(ans, sum[i]);
    sort(edges+1, edges+1+m, greater<tpiii>());
    for(int i=1; i<=min(m, max(1000LL, min(1000LL, m>>1))); i++){
        int c, u, v;
        tie(c, u, v) = edges[i];
        for(pii &tmp: G[u]){
            int f, k;
            tie(f, k) = tmp;
            ok[f] = 1;
            cost[f] = k;
        }
        for(pii &tmp: G[v]){
            int f, k;
            tie(f, k) = tmp;
            if(ok[f]) ans = max(ans, c + k + cost[f]);
        }
        for(pii &tmp: G[u]){
            int f, k;
            tie(f, k) = tmp;
            ok[f] = cost[f] = 0;
        }
    }
    cout << ans;
}

int32_t main(){
    fastIO;
    //file(TASK);

    nhap();
    solve();

    return 0;
}




Compilation message

pigus_skrydziai.cpp: In function 'void solve()':
pigus_skrydziai.cpp:66:29: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   66 |             ok[f] = cost[f] = 0;
      |                     ~~~~~~~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12636 KB Output is correct
2 Correct 3 ms 12736 KB Output is correct
3 Correct 2 ms 12636 KB Output is correct
4 Correct 3 ms 12636 KB Output is correct
5 Correct 2 ms 12636 KB Output is correct
6 Correct 8 ms 13404 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 3 ms 12636 KB Output is correct
9 Correct 2 ms 12632 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 2 ms 12636 KB Output is correct
12 Correct 3 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 2 ms 12636 KB Output is correct
15 Correct 3 ms 12632 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 3 ms 12636 KB Output is correct
18 Correct 3 ms 12636 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
21 Correct 2 ms 12636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 12636 KB Output is correct
2 Correct 3 ms 12736 KB Output is correct
3 Correct 2 ms 12636 KB Output is correct
4 Correct 3 ms 12636 KB Output is correct
5 Correct 2 ms 12636 KB Output is correct
6 Correct 8 ms 13404 KB Output is correct
7 Correct 2 ms 12636 KB Output is correct
8 Correct 3 ms 12636 KB Output is correct
9 Correct 2 ms 12632 KB Output is correct
10 Correct 2 ms 12636 KB Output is correct
11 Correct 2 ms 12636 KB Output is correct
12 Correct 3 ms 12636 KB Output is correct
13 Correct 2 ms 12636 KB Output is correct
14 Correct 2 ms 12636 KB Output is correct
15 Correct 3 ms 12632 KB Output is correct
16 Correct 2 ms 12636 KB Output is correct
17 Correct 3 ms 12636 KB Output is correct
18 Correct 3 ms 12636 KB Output is correct
19 Correct 3 ms 12892 KB Output is correct
20 Correct 2 ms 12636 KB Output is correct
21 Correct 2 ms 12636 KB Output is correct
22 Correct 194 ms 44884 KB Output is correct
23 Correct 141 ms 39236 KB Output is correct
24 Correct 10 ms 13912 KB Output is correct
25 Correct 4 ms 12976 KB Output is correct
26 Correct 4 ms 13092 KB Output is correct
27 Correct 4 ms 12944 KB Output is correct
28 Correct 59 ms 25660 KB Output is correct
29 Correct 25 ms 16476 KB Output is correct
30 Correct 38 ms 19132 KB Output is correct
31 Correct 3 ms 12636 KB Output is correct
32 Correct 3 ms 12636 KB Output is correct
33 Correct 140 ms 43148 KB Output is correct
34 Correct 95 ms 41980 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 25168 KB Output is correct
2 Correct 147 ms 35408 KB Output is correct
3 Correct 41 ms 22064 KB Output is correct
4 Correct 86 ms 29268 KB Output is correct
5 Correct 151 ms 36948 KB Output is correct
6 Correct 35 ms 18780 KB Output is correct
7 Correct 64 ms 33616 KB Output is correct
8 Correct 78 ms 33876 KB Output is correct
9 Correct 4 ms 15964 KB Output is correct
10 Correct 30 ms 18868 KB Output is correct
11 Correct 615 ms 35304 KB Output is correct
12 Correct 58 ms 27988 KB Output is correct
13 Correct 3 ms 12636 KB Output is correct
14 Correct 31 ms 20280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 25168 KB Output is correct
2 Correct 147 ms 35408 KB Output is correct
3 Correct 41 ms 22064 KB Output is correct
4 Correct 86 ms 29268 KB Output is correct
5 Correct 151 ms 36948 KB Output is correct
6 Correct 35 ms 18780 KB Output is correct
7 Correct 64 ms 33616 KB Output is correct
8 Correct 78 ms 33876 KB Output is correct
9 Correct 4 ms 15964 KB Output is correct
10 Correct 30 ms 18868 KB Output is correct
11 Correct 615 ms 35304 KB Output is correct
12 Correct 58 ms 27988 KB Output is correct
13 Correct 3 ms 12636 KB Output is correct
14 Correct 31 ms 20280 KB Output is correct
15 Correct 3 ms 12636 KB Output is correct
16 Correct 3 ms 12736 KB Output is correct
17 Correct 2 ms 12636 KB Output is correct
18 Correct 3 ms 12636 KB Output is correct
19 Correct 2 ms 12636 KB Output is correct
20 Correct 8 ms 13404 KB Output is correct
21 Correct 2 ms 12636 KB Output is correct
22 Correct 3 ms 12636 KB Output is correct
23 Correct 2 ms 12632 KB Output is correct
24 Correct 2 ms 12636 KB Output is correct
25 Correct 2 ms 12636 KB Output is correct
26 Correct 3 ms 12636 KB Output is correct
27 Correct 2 ms 12636 KB Output is correct
28 Correct 2 ms 12636 KB Output is correct
29 Correct 3 ms 12632 KB Output is correct
30 Correct 2 ms 12636 KB Output is correct
31 Correct 3 ms 12636 KB Output is correct
32 Correct 3 ms 12636 KB Output is correct
33 Correct 3 ms 12892 KB Output is correct
34 Correct 2 ms 12636 KB Output is correct
35 Correct 2 ms 12636 KB Output is correct
36 Correct 194 ms 44884 KB Output is correct
37 Correct 141 ms 39236 KB Output is correct
38 Correct 10 ms 13912 KB Output is correct
39 Correct 4 ms 12976 KB Output is correct
40 Correct 4 ms 13092 KB Output is correct
41 Correct 4 ms 12944 KB Output is correct
42 Correct 59 ms 25660 KB Output is correct
43 Correct 25 ms 16476 KB Output is correct
44 Correct 38 ms 19132 KB Output is correct
45 Correct 3 ms 12636 KB Output is correct
46 Correct 3 ms 12636 KB Output is correct
47 Correct 140 ms 43148 KB Output is correct
48 Correct 95 ms 41980 KB Output is correct
49 Correct 138 ms 30412 KB Output is correct
50 Correct 76 ms 28596 KB Output is correct
51 Correct 303 ms 31692 KB Output is correct
52 Correct 165 ms 36004 KB Output is correct
53 Correct 236 ms 23488 KB Output is correct
54 Correct 100 ms 40456 KB Output is correct
55 Correct 201 ms 42652 KB Output is correct
56 Correct 91 ms 34132 KB Output is correct
57 Incorrect 107 ms 35684 KB Output isn't correct
58 Halted 0 ms 0 KB -