답안 #502193

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
502193 2022-01-05T12:51:30 Z HappyPacMan 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
938 ms 73944 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]);
    }
    multiset<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);
            while(cnt[it.first].size() > 2) cnt[it.first].erase(--cnt[it.first].end());
            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 0 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 1 ms 432 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 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 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 1 ms 432 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 4 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 444 KB Output is correct
12 Correct 5 ms 824 KB Output is correct
13 Correct 3 ms 844 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 332 KB Output is correct
4 Correct 2 ms 460 KB Output is correct
5 Correct 1 ms 432 KB Output is correct
6 Correct 1 ms 460 KB Output is correct
7 Correct 1 ms 460 KB Output is correct
8 Correct 1 ms 460 KB Output is correct
9 Correct 4 ms 588 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 444 KB Output is correct
12 Correct 5 ms 824 KB Output is correct
13 Correct 3 ms 844 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 638 ms 59756 KB Output is correct
17 Correct 118 ms 27900 KB Output is correct
18 Correct 154 ms 28764 KB Output is correct
19 Correct 938 ms 73944 KB Output is correct
20 Correct 308 ms 47256 KB Output is correct
21 Correct 43 ms 10204 KB Output is correct
22 Correct 342 ms 48424 KB Output is correct