Submission #562654

# Submission time Handle Problem Language Result Execution time Memory
562654 2022-05-14T21:27:04 Z Iwanttobreakfree Crocodile's Underground City (IOI11_crocodile) C++
100 / 100
556 ms 77080 KB
#include <iostream>
#include <vector>
#include <queue>
#include "crocodile.h"
using namespace std;
typedef long long ll;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    vector<pair<ll,ll>> d(N,{1e18,1e18});
    vector<bool> seen(N,false);
    vector<vector<pair<int,ll>>> g(N,vector<pair<int,ll>>());
    for(int i=0;i<M;i++){
        g[R[i][0]].push_back({R[i][1],L[i]});
        g[R[i][1]].push_back({R[i][0],L[i]});
    }
    priority_queue<pair<ll,int>> pq;
    for(int i=0;i<K;i++){
        pq.push({0,P[i]});
        //seen[P[i]]=true;
        d[P[i]].first=d[P[i]].second=0;
    }
    while(!pq.empty()){
        ll dist=-pq.top().first,u=pq.top().second;
        pq.pop();
        //cout<<u<<' ';
        if(dist!=d[u].second||seen[u])continue;
        seen[u]=true;
        for(auto v:g[u]){
            if(seen[v.first])continue;
            if(dist+v.second<d[v.first].first){
                d[v.first].second=d[v.first].first;
                d[v.first].first=dist+v.second;
                if(d[v.first].first!=d[v.first].second)pq.push({-d[v.first].second,v.first});
            }
            else if(dist+v.second<d[v.first].second){
                d[v.first].second=dist+v.second;
                pq.push({-d[v.first].second,v.first});
            }
        }
    }
    return d[0].second;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 668 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 5 ms 972 KB Output is correct
13 Correct 3 ms 980 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 1 ms 468 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 668 KB Output is correct
10 Correct 1 ms 340 KB Output is correct
11 Correct 1 ms 464 KB Output is correct
12 Correct 5 ms 972 KB Output is correct
13 Correct 3 ms 980 KB Output is correct
14 Correct 1 ms 340 KB Output is correct
15 Correct 1 ms 340 KB Output is correct
16 Correct 463 ms 67544 KB Output is correct
17 Correct 93 ms 16556 KB Output is correct
18 Correct 111 ms 18824 KB Output is correct
19 Correct 556 ms 77080 KB Output is correct
20 Correct 262 ms 52360 KB Output is correct
21 Correct 38 ms 7240 KB Output is correct
22 Correct 301 ms 48816 KB Output is correct