답안 #550717

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
550717 2022-04-18T21:29:29 Z beaconmc 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
1494 ms 167120 KB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
    
typedef long long ll;
using namespace std;
using namespace __gnu_pbds;
    
#define FOR(i, x, y) for(ll i=x; i<y; i++)
#define FORNEG(i, x, y) for(ll i=x; i>y; i--)
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INF 2300000000
    
vector<ll> dist[100001];
vector<vector<ll>> edges[100001];
    
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
    
    FOR(i,0,M){
        edges[R[i][0]].push_back({R[i][1], L[i]});
        edges[R[i][1]].push_back({R[i][0], L[i]});
    }
    priority_queue<vector<ll>,vector<vector<ll>>,greater<vector<ll>>> pq;
    FOR(i,0,N){
        dist[i] = {INF, INF};
    }
    FOR(i,0,K){
        dist[P[i]] = {0,0};
        pq.push({0,P[i]});
    }
    
    
    while (pq.size()){
        vector<ll> node = pq.top();
        pq.pop();
    
        if (node[0] != dist[node[1]][1]) continue;
        for (auto&i : edges[node[1]]){
            if (node[0]+i[1] <= dist[i[0]][0]){
                if (dist[i[0]][0] != dist[i[0]][1]) pq.push({dist[i[0]][0], i[0]});
                dist[i[0]][1] = dist[i[0]][0];
                dist[i[0]][0] = node[0]+i[1];
            } else if (node[0]+i[1] < dist[i[0]][1]){
                dist[i[0]][1] = node[0]+i[1];
                pq.push({dist[i[0]][1], i[0]});
            }else{
                continue;
            }
        }
    }
    
    return dist[0][1];
    
}
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5020 KB Output is correct
4 Correct 4 ms 5204 KB Output is correct
5 Correct 4 ms 5204 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 4 ms 5204 KB Output is correct
8 Correct 3 ms 5148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5020 KB Output is correct
4 Correct 4 ms 5204 KB Output is correct
5 Correct 4 ms 5204 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 4 ms 5204 KB Output is correct
8 Correct 3 ms 5148 KB Output is correct
9 Correct 5 ms 5792 KB Output is correct
10 Correct 3 ms 5012 KB Output is correct
11 Correct 5 ms 5332 KB Output is correct
12 Correct 8 ms 6484 KB Output is correct
13 Correct 7 ms 6680 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 4 ms 5332 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4948 KB Output is correct
2 Correct 3 ms 4948 KB Output is correct
3 Correct 3 ms 5020 KB Output is correct
4 Correct 4 ms 5204 KB Output is correct
5 Correct 4 ms 5204 KB Output is correct
6 Correct 3 ms 5076 KB Output is correct
7 Correct 4 ms 5204 KB Output is correct
8 Correct 3 ms 5148 KB Output is correct
9 Correct 5 ms 5792 KB Output is correct
10 Correct 3 ms 5012 KB Output is correct
11 Correct 5 ms 5332 KB Output is correct
12 Correct 8 ms 6484 KB Output is correct
13 Correct 7 ms 6680 KB Output is correct
14 Correct 3 ms 5076 KB Output is correct
15 Correct 4 ms 5332 KB Output is correct
16 Correct 1231 ms 156128 KB Output is correct
17 Correct 106 ms 35604 KB Output is correct
18 Correct 186 ms 38420 KB Output is correct
19 Correct 1494 ms 167120 KB Output is correct
20 Correct 462 ms 134880 KB Output is correct
21 Correct 54 ms 19648 KB Output is correct
22 Correct 440 ms 128908 KB Output is correct