답안 #522623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
522623 2022-02-05T09:36:08 Z cig32 악어의 지하 도시 (IOI11_crocodile) C++17
100 / 100
821 ms 58088 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];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 304 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 436 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 432 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 304 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 436 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 432 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 4 ms 716 KB Output is correct
13 Correct 3 ms 828 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 304 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 436 KB Output is correct
7 Correct 1 ms 436 KB Output is correct
8 Correct 1 ms 432 KB Output is correct
9 Correct 2 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 4 ms 716 KB Output is correct
13 Correct 3 ms 828 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 560 ms 48328 KB Output is correct
17 Correct 92 ms 21644 KB Output is correct
18 Correct 125 ms 22552 KB Output is correct
19 Correct 821 ms 58088 KB Output is correct
20 Correct 297 ms 41088 KB Output is correct
21 Correct 41 ms 8316 KB Output is correct
22 Correct 349 ms 39012 KB Output is correct