Submission #502198

# Submission time Handle Problem Language Result Execution time Memory
502198 2022-01-05T12:57:47 Z HappyPacMan Crocodile's Underground City (IOI11_crocodile) C++14
100 / 100
661 ms 51776 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]);
    }
    priority_queue<long long> cnt[N];
    bool vis[N];
    long long dist[N];
    memset(vis,0,sizeof(vis));
    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();
        if(vis[curr.second]) continue;
        vis[curr.second] = true;
        for(auto it : adj[curr.second]){
            cnt[it.first].emplace(curr.first+it.second);
            while(cnt[it.first].size() > 2)cnt[it.first].pop();
            if(cnt[it.first].size() > 1 && dist[it.first] > cnt[it.first].top()){
                dist[it.first] = cnt[it.first].top();
                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 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
# 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 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 5 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 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 Correct 1 ms 332 KB Output is correct
4 Correct 1 ms 460 KB Output is correct
5 Correct 1 ms 460 KB Output is correct
6 Correct 1 ms 332 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 3 ms 460 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 5 ms 716 KB Output is correct
13 Correct 3 ms 716 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 447 ms 42008 KB Output is correct
17 Correct 90 ms 18368 KB Output is correct
18 Correct 115 ms 19260 KB Output is correct
19 Correct 661 ms 51776 KB Output is correct
20 Correct 267 ms 34444 KB Output is correct
21 Correct 39 ms 6876 KB Output is correct
22 Correct 279 ms 32388 KB Output is correct