Submission #748307

# Submission time Handle Problem Language Result Execution time Memory
748307 2023-05-26T05:15:49 Z Toxtaq Voting Cities (NOI22_votingcity) C++17
20 / 100
62 ms 860 KB
#include<bits/stdc++.h>
using namespace std;
vector<vector<pair<int, int>>>G;
vector<int>cities;
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    G.resize(n + 1);
    for(int i = 0;i < k;++i){
        int a;
        cin >> a;
        a++;
        cities.push_back(a);
    }
    for(int i = 0;i < m;++i){
        int u, v, c;
        cin >> u >> v >> c;
        u++;
        v++;
        G[u].push_back({v, c});
    }
    int q;
    cin >> q;
    while(q--){
        int s, p1, p2, p3, p4, p5;
        cin >> s >> p1 >> p2 >> p3 >> p4 >> p5;
        s++;
        long long mn = 1e18;
        priority_queue<pair<long long, int>>pq;
        vector<long long>dist(n + 1, 1e18); /// from s to other nodes
        vector<bool>check(n + 1);
        dist[s] = 0;
        pq.push({0, s});
        while(!pq.empty()){
            int cur = pq.top().second;
            pq.pop();
            if(check[cur])continue;
            check[cur] = 1;
            for(pair<long long, int>tempo : G[cur]){
                long long v = tempo.first, w = tempo.second;
                if(dist[v] > dist[cur] + w){
                    dist[v] = dist[cur] + w;
                    pq.push({-dist[v], v});
                }
            }
        }
        for(int i : cities){
            mn = min(mn, dist[i]);
        }
        if(mn == 1e18){
            cout << -1 << '\n';
        }
        else cout << mn << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 10 ms 724 KB Output is correct
2 Correct 6 ms 704 KB Output is correct
3 Correct 10 ms 852 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 724 KB Output is correct
2 Correct 6 ms 704 KB Output is correct
3 Correct 10 ms 852 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 44 ms 732 KB Output is correct
7 Correct 14 ms 596 KB Output is correct
8 Correct 59 ms 852 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 724 KB Output is correct
2 Correct 6 ms 704 KB Output is correct
3 Correct 10 ms 852 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 44 ms 732 KB Output is correct
7 Correct 14 ms 596 KB Output is correct
8 Correct 59 ms 852 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 50 ms 760 KB Output is correct
12 Correct 15 ms 596 KB Output is correct
13 Correct 62 ms 852 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 724 KB Output is correct
2 Correct 6 ms 704 KB Output is correct
3 Correct 10 ms 852 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 10 ms 748 KB Output is correct
7 Correct 5 ms 596 KB Output is correct
8 Correct 14 ms 860 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 10 ms 724 KB Output is correct
2 Correct 6 ms 704 KB Output is correct
3 Correct 10 ms 852 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 44 ms 732 KB Output is correct
7 Correct 14 ms 596 KB Output is correct
8 Correct 59 ms 852 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 10 ms 748 KB Output is correct
12 Correct 5 ms 596 KB Output is correct
13 Correct 14 ms 860 KB Output is correct
14 Incorrect 50 ms 800 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 44 ms 724 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 10 ms 724 KB Output is correct
2 Correct 6 ms 704 KB Output is correct
3 Correct 10 ms 852 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 44 ms 732 KB Output is correct
7 Correct 14 ms 596 KB Output is correct
8 Correct 59 ms 852 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 50 ms 760 KB Output is correct
12 Correct 15 ms 596 KB Output is correct
13 Correct 62 ms 852 KB Output is correct
14 Correct 0 ms 212 KB Output is correct
15 Correct 0 ms 212 KB Output is correct
16 Correct 10 ms 748 KB Output is correct
17 Correct 5 ms 596 KB Output is correct
18 Correct 14 ms 860 KB Output is correct
19 Incorrect 50 ms 800 KB Output isn't correct
20 Halted 0 ms 0 KB -