답안 #985348

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
985348 2024-05-17T16:32:41 Z CrazyBotBoy 사이버랜드 (APIO23_cyberland) C++17
15 / 100
1464 ms 2097152 KB
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <limits>
#include <tuple>
#include <iomanip>

const double INF = std::numeric_limits<double>::infinity();

struct State {
    double time;
    int country;
    int div2_used;

    bool operator>(const State& other) const {
        return time > other.time;
    }
};

double solve(int N, int M, int K, int H, std::vector<int> x, std::vector<int> y, std::vector<int> c, std::vector<int> arr) {
    std::vector<std::vector<std::pair<int, double>>> graph(N);

    for (int i = 0; i < M; ++i) {
        graph[x[i]].emplace_back(y[i], c[i]);
        graph[y[i]].emplace_back(x[i], c[i]);
    }

    std::priority_queue<State, std::vector<State>, std::greater<State>> pq;
    pq.push({0, 0, 0});

    std::vector<std::vector<double>> dist(N, std::vector<double>(K + 1, INF));
    dist[0][0] = 0;

    while (!pq.empty()) {
        auto [current_time, current_country, div2_used] = pq.top();
        pq.pop();

        if (current_country == H) {
            return current_time;
        }

        if (current_time > dist[current_country][div2_used]) {
            continue;
        }

        for (const auto& [next_country, travel_time] : graph[current_country]) {
            double next_time = current_time + travel_time;

            if (next_time < dist[next_country][div2_used]) {
                dist[next_country][div2_used] = next_time;
                pq.push({next_time, next_country, div2_used});
            }

            if (arr[next_country] == 0) {
                next_time = 0;
                if (next_time < dist[next_country][div2_used]) {
                    dist[next_country][div2_used] = next_time;
                    pq.push({next_time, next_country, div2_used});
                }
            } else if (arr[next_country] == 2 && div2_used < K) {
                next_time = current_time / 2.0;
                if (next_time < dist[next_country][div2_used + 1]) {
                    dist[next_country][div2_used + 1] = next_time;
                    pq.push({next_time, next_country, div2_used + 1});
                }
            }
        }
    }

    return -1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 16 ms 856 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 19 ms 1724 KB Correct.
2 Correct 24 ms 1736 KB Correct.
3 Correct 26 ms 1836 KB Correct.
4 Correct 27 ms 1628 KB Correct.
5 Correct 23 ms 1800 KB Correct.
6 Correct 18 ms 4860 KB Correct.
7 Correct 25 ms 4980 KB Correct.
8 Correct 12 ms 8284 KB Correct.
9 Correct 23 ms 1372 KB Correct.
10 Correct 23 ms 1424 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 1628 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 119 ms 22620 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 20 ms 1700 KB Correct.
2 Correct 23 ms 1884 KB Correct.
3 Correct 27 ms 1852 KB Correct.
4 Correct 21 ms 4504 KB Correct.
5 Correct 20 ms 1380 KB Correct.
# 결과 실행 시간 메모리 Grader output
1 Incorrect 24 ms 1628 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 149 ms 2144 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1464 ms 2097152 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -