답안 #426109

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
426109 2021-06-13T14:14:23 Z someone 악어의 지하 도시 (IOI11_crocodile) C++14
100 / 100
930 ms 77984 KB
#include "crocodile.h"
#include <bits/stdc++.h>
#define ll long long
using namespace std;

struct Node {
    ll i, t;

    bool operator <(const Node& other) const {
        return t > other.t;
    }
};

const ll N = 1e5 + 10, INF = 1e18;

priority_queue<Node> q;
vector<ll> adj[N], len[N];
ll n, m, dist[N][2];

void Dijkstra() {
    while(!q.empty()) {
        Node node = q.top();
        q.pop();
        int i = node.i, t = adj[i].size();
        if(dist[i][1] == node.t) {
            for(int j = 0; j < t; j++) {
                ll nex = adj[i][j],
                   time = dist[i][1] + len[i][j];
                   
                if(time < dist[nex][0])
                    swap(time, dist[nex][0]);
                if(time < dist[nex][1]) {
                    swap(time, dist[nex][1]);
                    q.push({nex, dist[nex][1]});
                }
            }
        }
    }
}

int travel_plan(int n1, int m1, int R[][2], int L[], int K, int P[]) {
    n = n1, m = m1;
    for(int i = 0; i < m; i++) {
        len[R[i][0]].push_back(L[i]);
        len[R[i][1]].push_back(L[i]);
        adj[R[i][0]].push_back(R[i][1]);
        adj[R[i][1]].push_back(R[i][0]);
    }
    for(int i = 0; i < n; i++)
        dist[i][0] = dist[i][1] = INF;
    for(int i = 0; i < K; i++)
        dist[P[i]][0] = dist[P[i]][1] = 0;
    for(int i = 0; i < K; i++)
        q.push({P[i], 0});
    Dijkstra();
    return dist[0][1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5008 KB Output is correct
2 Correct 3 ms 5008 KB Output is correct
3 Correct 5 ms 5012 KB Output is correct
4 Correct 6 ms 5068 KB Output is correct
5 Correct 5 ms 5068 KB Output is correct
6 Correct 6 ms 5068 KB Output is correct
7 Correct 6 ms 5068 KB Output is correct
8 Correct 4 ms 5148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5008 KB Output is correct
2 Correct 3 ms 5008 KB Output is correct
3 Correct 5 ms 5012 KB Output is correct
4 Correct 6 ms 5068 KB Output is correct
5 Correct 5 ms 5068 KB Output is correct
6 Correct 6 ms 5068 KB Output is correct
7 Correct 6 ms 5068 KB Output is correct
8 Correct 4 ms 5148 KB Output is correct
9 Correct 6 ms 5452 KB Output is correct
10 Correct 4 ms 4940 KB Output is correct
11 Correct 7 ms 5148 KB Output is correct
12 Correct 8 ms 5748 KB Output is correct
13 Correct 7 ms 5836 KB Output is correct
14 Correct 5 ms 5012 KB Output is correct
15 Correct 4 ms 5148 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 5008 KB Output is correct
2 Correct 3 ms 5008 KB Output is correct
3 Correct 5 ms 5012 KB Output is correct
4 Correct 6 ms 5068 KB Output is correct
5 Correct 5 ms 5068 KB Output is correct
6 Correct 6 ms 5068 KB Output is correct
7 Correct 6 ms 5068 KB Output is correct
8 Correct 4 ms 5148 KB Output is correct
9 Correct 6 ms 5452 KB Output is correct
10 Correct 4 ms 4940 KB Output is correct
11 Correct 7 ms 5148 KB Output is correct
12 Correct 8 ms 5748 KB Output is correct
13 Correct 7 ms 5836 KB Output is correct
14 Correct 5 ms 5012 KB Output is correct
15 Correct 4 ms 5148 KB Output is correct
16 Correct 759 ms 70912 KB Output is correct
17 Correct 105 ms 20396 KB Output is correct
18 Correct 137 ms 21932 KB Output is correct
19 Correct 930 ms 77984 KB Output is correct
20 Correct 338 ms 62744 KB Output is correct
21 Correct 85 ms 12080 KB Output is correct
22 Correct 400 ms 54816 KB Output is correct