Submission #645940

# Submission time Handle Problem Language Result Execution time Memory
645940 2022-09-28T10:17:24 Z mychecksedad Toll (BOI17_toll) C++17
0 / 100
42 ms 27312 KB
/* Author : Mychecksdead */
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define MOD (1000000000+7)
#define MOD1 (998244353)
#define PI 3.1415926535
#define pb push_back
#define setp() cout << setprecision(15)
#define all(x) x.begin(), x.end()
#define debug(x) cerr << #x << " is " << x << '\n';
const int N = 1e6+100, M = 1e5+10, F = 2147483646, K = 20;



int n, m, k, qq;
vector<pair<int, int>> g[N];
     
void solve(){
    cin >> k >> n >> m >> qq;
    for(int i = 0; i < m; ++i){
        int u, v, e; cin >> u >> v >> e;
        g[u].pb({v, e});
    }
    priority_queue<pair<ll, int>> q;
    q.push({0, 0});
    vector<bool> used(n + 1);
    vector<ll> dist(n + 1, 1e18);
    dist[0] = 0;
    while(!q.empty()){
        int v = q.top().second; q.pop();
        if(used[v]) continue;
        used[v] = 1;
        for(auto u: g[v]){
            if(dist[u.first] > dist[v] + u.second){
                dist[u.first] = dist[v] + u.second;
                q.push({-dist[u.first], u.second});
            }
        }
    }
    for(;qq--;){
        int a, b; cin >> a >> b;
        if(dist[b] == 1e18) cout << "-1\n";
        else cout << dist[b] << '\n';
    }   
}





int main(){
    cin.tie(0); ios::sync_with_stdio(0);
    int T = 1, aa;
    // cin >> T;aa=T;
    while(T--){
        // cout << "Case #" << aa-T << ": ";
        solve();
        cout << '\n';
    }
    return 0;
 
}

Compilation message

toll.cpp: In function 'int main()':
toll.cpp:55:16: warning: unused variable 'aa' [-Wunused-variable]
   55 |     int T = 1, aa;
      |                ^~
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 26680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 42 ms 27312 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 23764 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 30 ms 26680 KB Output isn't correct
2 Halted 0 ms 0 KB -