답안 #502180

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502180 2022-01-05T12:35:00 Z HappyPacMan 악어의 지하 도시 (IOI11_crocodile) C++14
0 / 100
2 ms 432 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];
    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);
            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];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Incorrect 2 ms 432 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Incorrect 2 ms 432 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 260 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 1 ms 304 KB Output is correct
4 Incorrect 2 ms 432 KB Output isn't correct
5 Halted 0 ms 0 KB -