Submission #1113822

# Submission time Handle Problem Language Result Execution time Memory
1113822 2024-11-17T14:01:08 Z Aviansh Relay Marathon (NOI20_relaymarathon) C++17
17 / 100
874 ms 1048576 KB
#include <bits/stdc++.h>

using namespace std;

signed main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n,m,k;
    cin >> n >> m >> k;
    int dist[n][n];
    for(int i = 0;i<n;i++){
        for(int j = 0;j<n;j++){
            dist[i][j]=1e9;
        }
        dist[i][i]=0;
    }
    for(int i = 0;i<m;i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        dist[u][v]=w;
        dist[v][u]=w;
    }
    for(int k = 0;k<n;k++){
        for(int i = 0;i<n;i++){
            for(int j = 0;j<n;j++){
                dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
            }
        }
    }
    int spec[k];
    for(int i = 0;i<k;i++){
        cin >> spec[i];
        spec[i]--;
    }
    vector<pair<int,int>>d[k];
    for(int i = 0;i<k;i++){
        for(int j = i+1;j<k;j++){
            d[i].push_back({dist[spec[i]][spec[j]],j});
        }
        sort(d[i].begin(),d[i].end());
    }
    int ans = 2e9;
    for(int i = 0;i<k;i++){
        for(int j = i+1;j<k;j++){
            for(int l = 0;l<k;l++){
                if(i==l||j==l){
                    continue;
                }
                for(pair<int,int>p : d[l]){
                    if(p.second==i||p.second==j)
                        continue;
                    ans=min(ans,dist[spec[i]][spec[j]]+p.first);
                    break;
                }
            }
        }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 568 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 568 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 113 ms 1360 KB Output is correct
32 Correct 116 ms 1528 KB Output is correct
33 Correct 117 ms 1360 KB Output is correct
34 Correct 122 ms 1532 KB Output is correct
35 Correct 114 ms 1528 KB Output is correct
36 Correct 136 ms 1868 KB Output is correct
37 Correct 254 ms 2640 KB Output is correct
38 Correct 113 ms 1360 KB Output is correct
39 Correct 127 ms 2376 KB Output is correct
40 Correct 137 ms 1884 KB Output is correct
41 Correct 113 ms 1360 KB Output is correct
42 Correct 179 ms 2384 KB Output is correct
43 Correct 145 ms 1708 KB Output is correct
44 Correct 116 ms 1360 KB Output is correct
45 Correct 118 ms 1360 KB Output is correct
46 Correct 189 ms 3396 KB Output is correct
47 Correct 149 ms 1864 KB Output is correct
48 Correct 134 ms 2128 KB Output is correct
49 Correct 149 ms 2632 KB Output is correct
50 Correct 121 ms 1340 KB Output is correct
51 Correct 170 ms 1948 KB Output is correct
52 Correct 120 ms 1360 KB Output is correct
53 Correct 125 ms 1872 KB Output is correct
54 Correct 135 ms 2444 KB Output is correct
55 Correct 125 ms 1360 KB Output is correct
56 Correct 123 ms 1416 KB Output is correct
57 Correct 121 ms 1360 KB Output is correct
58 Correct 140 ms 2888 KB Output is correct
59 Correct 118 ms 1360 KB Output is correct
60 Correct 152 ms 1956 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 874 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 504 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 2 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 2 ms 336 KB Output is correct
15 Correct 2 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 1 ms 336 KB Output is correct
18 Correct 1 ms 336 KB Output is correct
19 Correct 1 ms 336 KB Output is correct
20 Correct 1 ms 336 KB Output is correct
21 Correct 1 ms 336 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 2 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Correct 1 ms 336 KB Output is correct
26 Correct 1 ms 336 KB Output is correct
27 Correct 1 ms 568 KB Output is correct
28 Correct 1 ms 336 KB Output is correct
29 Correct 1 ms 336 KB Output is correct
30 Correct 1 ms 336 KB Output is correct
31 Correct 113 ms 1360 KB Output is correct
32 Correct 116 ms 1528 KB Output is correct
33 Correct 117 ms 1360 KB Output is correct
34 Correct 122 ms 1532 KB Output is correct
35 Correct 114 ms 1528 KB Output is correct
36 Correct 136 ms 1868 KB Output is correct
37 Correct 254 ms 2640 KB Output is correct
38 Correct 113 ms 1360 KB Output is correct
39 Correct 127 ms 2376 KB Output is correct
40 Correct 137 ms 1884 KB Output is correct
41 Correct 113 ms 1360 KB Output is correct
42 Correct 179 ms 2384 KB Output is correct
43 Correct 145 ms 1708 KB Output is correct
44 Correct 116 ms 1360 KB Output is correct
45 Correct 118 ms 1360 KB Output is correct
46 Correct 189 ms 3396 KB Output is correct
47 Correct 149 ms 1864 KB Output is correct
48 Correct 134 ms 2128 KB Output is correct
49 Correct 149 ms 2632 KB Output is correct
50 Correct 121 ms 1340 KB Output is correct
51 Correct 170 ms 1948 KB Output is correct
52 Correct 120 ms 1360 KB Output is correct
53 Correct 125 ms 1872 KB Output is correct
54 Correct 135 ms 2444 KB Output is correct
55 Correct 125 ms 1360 KB Output is correct
56 Correct 123 ms 1416 KB Output is correct
57 Correct 121 ms 1360 KB Output is correct
58 Correct 140 ms 2888 KB Output is correct
59 Correct 118 ms 1360 KB Output is correct
60 Correct 152 ms 1956 KB Output is correct
61 Runtime error 874 ms 1048576 KB Execution killed with signal 9
62 Halted 0 ms 0 KB -