Submission #1009879

# Submission time Handle Problem Language Result Execution time Memory
1009879 2024-06-28T07:09:18 Z Mardonbekhazratov Crocodile's Underground City (IOI11_crocodile) C++17
100 / 100
412 ms 66260 KB
#include "crocodile.h"
#include<bits/stdc++.h>
#define ll long long
using namespace std;

vector<bool>vis;
vector<vector<pair<int,int>>>v;
vector<priority_queue<int>>dp;

const int INF=1e9;


int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    vis.assign(N,false);
    v.resize(N);
    for(int i=0;i<M;i++){
        v[R[i][0]].push_back({R[i][1],L[i]});
        v[R[i][1]].push_back({R[i][0],L[i]});
    }
    dp.resize(N);
    priority_queue<pair<int,int>>q;
    vector<int>ans(N);
    for(int i=0;i<K;i++){
        q.push({0,P[i]});
        dp[P[i]].push(0);
        ans[P[i]]=0;
    }
    while(!q.empty()){
        auto [d,x]=q.top();
        q.pop();
        if(vis[x]) continue;
        vis[x]=true;
        d=-d;
        ans[x]=d;
        for(auto [z,w]:v[x]){
            if(vis[z]) continue;
            if(dp[z].size()<2){
                dp[z].push(d+w);
            }
            else if(d+w<dp[z].top()){
                dp[z].pop();
                dp[z].push(d+w);
            }
            if(dp[z].size()==2){
                q.push({-dp[z].top(),z});
            }
        }
    }
    return ans[0];
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 608 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 608 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 352 KB Output is correct
11 Correct 1 ms 608 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 1 ms 488 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 608 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 352 KB Output is correct
11 Correct 1 ms 608 KB Output is correct
12 Correct 3 ms 860 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 0 ms 352 KB Output is correct
15 Correct 1 ms 488 KB Output is correct
16 Correct 357 ms 64196 KB Output is correct
17 Correct 49 ms 19544 KB Output is correct
18 Correct 60 ms 20796 KB Output is correct
19 Correct 412 ms 66260 KB Output is correct
20 Correct 272 ms 51416 KB Output is correct
21 Correct 24 ms 7932 KB Output is correct
22 Correct 270 ms 46228 KB Output is correct