제출 #1358442

#제출 시각아이디문제언어결과실행 시간메모리
1358442orgiloogii사이버랜드 (APIO23_cyberland)C++20
5 / 100
2960 ms94328 KiB
#include "cyberland.h"
#include <bits/stdc++.h>
#include <vector>
#define ff first
#define ss second
using namespace std;
vector <vector <array <double, 2>>> adj;
vector <vector <double>> dp;
const double inf = 1e18;
double solve(int n, int m, int k, int h, vector<int> x, vector<int> y, vector<int> c, vector<int> arr) {
    k = min(k, 70);
    adj.assign(n + 1, {});
    dp.assign(n + 1, vector <double> (k + 1, inf));
    for (int i = 0;i < m;i++) {
        adj[x[i]].push_back({y[i], c[i]});
        adj[y[i]].push_back({x[i], c[i]});
    }
    vector <int> zer;
    zer.push_back(0);
    vector <bool> vis(n + 1, 0);
    queue <int> q;
    q.push(0);
    vis[0] = true;
    while (!q.empty()) {
        auto u = q.front();
        q.pop();
        for (auto [v, _] : adj[u]) {
            if (vis[v]) continue;
            if (v == h) {
                vis[h] = true;
                continue;
            }
            vis[v] = true;
            if (arr[v] == 0) {
                zer.push_back(v);
            }
            q.push(v);
        }
    }
    if (!vis[h]) return -1.0;
    priority_queue <pair <double, pair <int, int>>, vector <pair <double, pair <int, int>>>, greater <pair <double, pair <int, int>>>> pq; 
    for (auto x : zer) {
        for (int i = 0;i <= k;i++) {
            dp[x][i] = 0;
        }
        pq.push({0.0, {x, 0}});
    }
    while (!pq.empty()) {
        auto curr = pq.top().ff;
        auto x = pq.top().ss.ff;
        auto y = pq.top().ss.ss;
        pq.pop();
        if (dp[x][y] < curr || x == h) continue;
        for (auto [v, w] : adj[x]) {
            if (arr[v] == 0) continue;
            if (dp[v][y] > curr + w) {
                dp[v][y] = curr + w;
                pq.push({curr + w, {v, y}});
            } 
            if (arr[v] == 2 && y < k && dp[v][y + 1] > (curr + w) / 2) {
                dp[v][y + 1] = (curr + w) / 2;
                pq.push({(curr + w) / 2, {v, y + 1}});
            }
        }
    }
    double ans = INT_MAX;
    for (int i = 0;i <= k;i++) {
        ans = min(ans, dp[h][i]);
    }
    return ans;
}

컴파일 시 표준 에러 (stderr) 메시지

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:15:28: warning: narrowing conversion of 'y.std::vector<int>::operator[](((std::vector<int>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'double' [-Wnarrowing]
   15 |         adj[x[i]].push_back({y[i], c[i]});
      |         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
cyberland.cpp:15:28: warning: narrowing conversion of 'c.std::vector<int>::operator[](((std::vector<int>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'double' [-Wnarrowing]
cyberland.cpp:16:28: warning: narrowing conversion of 'x.std::vector<int>::operator[](((std::vector<int>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'double' [-Wnarrowing]
   16 |         adj[y[i]].push_back({x[i], c[i]});
      |         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
cyberland.cpp:16:28: warning: narrowing conversion of 'c.std::vector<int>::operator[](((std::vector<int>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'} to 'double' [-Wnarrowing]
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…