답안 #1009881

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1009881 2024-06-28T07:12:39 Z Mardonbekhazratov 악어의 지하 도시 (IOI11_crocodile) C++17
46 / 100
2 ms 604 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(dp[x].top()+w);
            }
            else if(dp[x].top()+w<dp[z].top()){
                dp[z].pop();
                dp[z].push(dp[x].top()+w);
            }
            if(dp[z].size()==2){
                q.push({-dp[z].top(),z});
            }
        }
    }
    return ans[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 2 ms 604 KB Output isn't correct
10 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Incorrect 2 ms 604 KB Output isn't correct
10 Halted 0 ms 0 KB -