제출 #1367496

#제출 시각아이디문제언어결과실행 시간메모리
1367496aaatroush사이버랜드 (APIO23_cyberland)C++20
컴파일 에러
0 ms0 KiB
#include "cyberland.h"
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
#define pb push_back
#define pii tuple<double, int, int>
#define in(v) for(auto &elem:v){ cin>>elem; }
#define out(v) for(auto elem:v){ cout<<elem<<" "; } cout<<endl;
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef tree<pii, null_type, std::greater<>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


double solve(int n, int m, int k, int h, vector<int> &x, vector<int> &y, vector<int> &cc, vector<int> &arr) {
    k = min(k, 67);
    vector<vector<pair<int, int>>> adj(n);
    for(int i = 0; i<m; i++){
        int u = x[i], v = y[i], c = cc[i];
        adj[u].pb({c, v});
        adj[v].pb({c, u});
    }

    const ll inf = 4e18;
    //out(vis)

    
    priority_queue<pii, vector<pii>, greater<pii>> pq;
    vector<vector<double>> dist(n, vector<double>(k + 1, inf));
    pq.push({0, 0, 0});
    dist[0][0] = 0;
    double ans = inf;
    while(!pq.empty()){
        auto [c, u, op] = pq.top();
        pq.pop();
        if(c > dist[u][op]){
            continue;
        }
        if(u == h){
            ans = min(c, ans);
            continue;
        }

        for(auto [c, v] : adj[u]){
            double ch1 = dist[u][op] + c;
            if(arr[v] == 0) ch1 = 0;

            if(ch1 < dist[v][op]){
                dist[v][op] = ch1;
                pq.push({ch1, v, op});
            }

            if(op < k && arr[u] == 2){
                double ch2 = dist[u][op] / 2 + c;
                if(arr[v] == 0) ch2 = 0;

                if(ch2 < dist[v][op+1]){
                    dist[v][op + 1] = ch2;
                    pq.push({ch2, v, op + 1});
                }
            }
        }
    }

    if(ans >= 3e18){
        return -1;
    }
    return ans;
}
/*int main(){
    int n, m, k, h;
    cin>>n>>m>>k>>h;
    vector<int> x(m), y(m), c(m), arr(n);
    for(ll i = 0; i<m; i++){
        cin>>x[i]>>y[i]>>c[i];
    }
    for(ll i = 0; i<n; i++){
        cin>>arr[i];
    }
    cout<<solve(n, m, k, h, x, y, c, arr);
}*/

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

/usr/bin/ld: /tmp/cccr757j.o: in function `main':
grader.cpp:(.text.startup+0x700): undefined reference to `solve(int, int, int, int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status