Submission #498265

# Submission time Handle Problem Language Result Execution time Memory
498265 2021-12-24T17:55:22 Z Kipras Cheap flights (LMIO18_pigus_skrydziai) C++14
0 / 100
181 ms 39080 KB
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;

const int maxN = 1e5*3+1;

int n, m;
vector<pair<int, int>> adj[maxN];

int main()
{

    ios_base::sync_with_stdio(0);cin.tie(nullptr);

    cin>>n>>m;
    for(int i = 0; i < m; i++){
        int a, b, c;
        cin>>a>>b>>c;
        adj[a].push_back({b, c});
        adj[b].push_back({a, c});
    }

    ll ans=0;

    for(int i = 1; i <= n; i++){
        ll temp=0;
        for(auto x : adj[i]){
            temp+=x.second;
        }
        ans=max(ans, temp);
    }

    for(int i = 1; i <= n; i++){
        for(int x = 0; x < adj[i].size()-1; x++){
            ll temp=0;
            int val=-1;
            int v1=adj[i][x].first, v2=adj[i][x+1].first;
            if(adj[v1].size()<adj[v2].size()){
                for(auto z : adj[v1]){
                    if(z.first==v2){
                        val=z.second;
                        break;
                    }
                }
            }else{
                for(auto z : adj[v2]){
                    if(z.first==v1){
                        val=z.second;
                        break;
                    }
                }
            }
            if(val==-1)continue;
            temp=adj[i][x].second+adj[i][x+1].second+val;
            ans=max(ans, temp);
        }
    }

    cout<<ans;

    return 0;
}

Compilation message

pigus_skrydziai.cpp: In function 'int main()':
pigus_skrydziai.cpp:35:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int x = 0; x < adj[i].size()-1; x++){
      |                        ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7244 KB Output is correct
2 Correct 4 ms 7244 KB Output is correct
3 Correct 4 ms 7360 KB Output is correct
4 Correct 5 ms 7368 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 11 ms 7920 KB Output is correct
7 Correct 5 ms 7360 KB Output is correct
8 Correct 4 ms 7372 KB Output is correct
9 Correct 5 ms 7376 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7376 KB Output is correct
12 Correct 4 ms 7364 KB Output is correct
13 Correct 4 ms 7248 KB Output is correct
14 Correct 4 ms 7360 KB Output is correct
15 Correct 4 ms 7248 KB Output is correct
16 Correct 4 ms 7348 KB Output is correct
17 Correct 5 ms 7356 KB Output is correct
18 Correct 6 ms 7368 KB Output is correct
19 Correct 5 ms 7376 KB Output is correct
20 Correct 5 ms 7248 KB Output is correct
21 Runtime error 10 ms 14672 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7244 KB Output is correct
2 Correct 4 ms 7244 KB Output is correct
3 Correct 4 ms 7360 KB Output is correct
4 Correct 5 ms 7368 KB Output is correct
5 Correct 4 ms 7248 KB Output is correct
6 Correct 11 ms 7920 KB Output is correct
7 Correct 5 ms 7360 KB Output is correct
8 Correct 4 ms 7372 KB Output is correct
9 Correct 5 ms 7376 KB Output is correct
10 Correct 4 ms 7248 KB Output is correct
11 Correct 4 ms 7376 KB Output is correct
12 Correct 4 ms 7364 KB Output is correct
13 Correct 4 ms 7248 KB Output is correct
14 Correct 4 ms 7360 KB Output is correct
15 Correct 4 ms 7248 KB Output is correct
16 Correct 4 ms 7348 KB Output is correct
17 Correct 5 ms 7356 KB Output is correct
18 Correct 6 ms 7368 KB Output is correct
19 Correct 5 ms 7376 KB Output is correct
20 Correct 5 ms 7248 KB Output is correct
21 Runtime error 10 ms 14672 KB Execution killed with signal 11
# Verdict Execution time Memory Grader output
1 Correct 76 ms 18848 KB Output is correct
2 Correct 181 ms 21100 KB Output is correct
3 Correct 58 ms 11748 KB Output is correct
4 Correct 130 ms 16584 KB Output is correct
5 Runtime error 171 ms 39080 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 76 ms 18848 KB Output is correct
2 Correct 181 ms 21100 KB Output is correct
3 Correct 58 ms 11748 KB Output is correct
4 Correct 130 ms 16584 KB Output is correct
5 Runtime error 171 ms 39080 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -