Submission #502184

# Submission time Handle Problem Language Result Execution time Memory
502184 2022-01-05T12:37:10 Z HappyPacMan Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
1 ms 332 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    vector<pair<int,int> > adj[N];
    for(int i=0;i<M;i++){
        adj[R[i][0]].emplace_back(R[i][1],L[i]);
        adj[R[i][1]].emplace_back(R[i][0],L[i]);
    }
    set<int> cnt[N];
    long long dist[N];
    memset(dist,127,sizeof(dist));
    priority_queue<pair<long long,int>,vector<pair<long long,int> >,greater<pair<int,int> > > pq;
    for(int i=0;i<K;i++){
        dist[P[i]] = 0;
        pq.emplace(dist[P[i]],P[i]);
    }
    while(!pq.empty()){
        auto curr = pq.top();
        pq.pop();
        for(auto it : adj[curr.second]){
            cnt[it.first].emplace(curr.first+it.second);
            while(cnt[it.first].size() > 2) cnt[it.first].erase(*(--cnt[it.first].end()));
            if(cnt[it.first].size() > 1 && dist[it.first] > *(++cnt[it.first].begin())){
                dist[it.first] = *(++cnt[it.first].begin());
                pq.emplace(dist[it.first],it.first);
            }
        }
    }
    return dist[0];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Incorrect 1 ms 332 KB Output isn't correct
4 Halted 0 ms 0 KB -