Submission #1314232

#TimeUsernameProblemLanguageResultExecution timeMemory
1314232aaaaaaaaCyberland (APIO23_cyberland)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>
#include "cyberland.h"
using namespace std;
const double inf = 1e18;
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) {
    vector<pair<int, double>> adj[N + 1];
    for(int i = 0; i < M; ++i){
        adj[x[i]].push_back({y[i], (double) c[i] * 1.00});
        adj[y[i]].push_back({x[i], (double) c[i]} * 1.00});
    }
    vector<vector<double>> dp(N + 1, vector<double>(K + 1, inf));
    priority_queue<tuple<int, int, int>> pq;
    pq.push({0, -K, 0}); dp[0][K] = 0;
    while(pq.size()){
        auto [dist, rem, node] = pq.top();
        pq.pop(); dist = -dist, rem = -rem;
        if(node == H) continue;
        if(arr[node] == 0) dist = 0;
        if(dp[node][rem] < dist) continue;
        for(auto [v, w] : adj[node]){
            if(dp[v][rem] > dist + w){
                dp[v][rem] = dist + w;
                pq.push({-dp[v][rem], -rem, v});
            }
            if(arr[node] == 2 && rem && dist > 0.0){
                if(dp[v][rem - 1] > (dist / 2.0) + w){
                    dp[v][rem - 1] = (dist / 2.0) + w;
                    pq.push({-dp[v][rem - 1], -(rem - 1), v});
                }
            }
        }
    }
    double ans = inf;
    for(int i = 0; i <= K; ++i) ans = min(ans, dp[H][i]);
    return ((ans >= inf) ? -1 : ans);
}

Compilation message (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:9:50: error: expected ')' before '*' token
    9 |         adj[y[i]].push_back({x[i], (double) c[i]} * 1.00});
      |                            ~                     ^~
      |                                                  )
cyberland.cpp:9:58: error: expected primary-expression before ')' token
    9 |         adj[y[i]].push_back({x[i], (double) c[i]} * 1.00});
      |                                                          ^
cyberland.cpp:10:5: warning: no return statement in function returning non-void [-Wreturn-type]
   10 |     }
      |     ^
cyberland.cpp: At global scope:
cyberland.cpp:11:31: error: 'N' was not declared in this scope
   11 |     vector<vector<double>> dp(N + 1, vector<double>(K + 1, inf));
      |                               ^
cyberland.cpp:11:53: error: 'K' was not declared in this scope
   11 |     vector<vector<double>> dp(N + 1, vector<double>(K + 1, inf));
      |                                                     ^
cyberland.cpp:13:5: error: 'pq' does not name a type
   13 |     pq.push({0, -K, 0}); dp[0][K] = 0;
      |     ^~
cyberland.cpp:13:23: error: expected unqualified-id before ')' token
   13 |     pq.push({0, -K, 0}); dp[0][K] = 0;
      |                       ^
cyberland.cpp:13:26: error: 'dp' does not name a type
   13 |     pq.push({0, -K, 0}); dp[0][K] = 0;
      |                          ^~
cyberland.cpp:14:5: error: expected unqualified-id before 'while'
   14 |     while(pq.size()){
      |     ^~~~~
cyberland.cpp:34:5: error: expected unqualified-id before 'for'
   34 |     for(int i = 0; i <= K; ++i) ans = min(ans, dp[H][i]);
      |     ^~~
cyberland.cpp:34:20: error: 'i' does not name a type
   34 |     for(int i = 0; i <= K; ++i) ans = min(ans, dp[H][i]);
      |                    ^
cyberland.cpp:34:28: error: expected unqualified-id before '++' token
   34 |     for(int i = 0; i <= K; ++i) ans = min(ans, dp[H][i]);
      |                            ^~
cyberland.cpp:35:5: error: expected unqualified-id before 'return'
   35 |     return ((ans >= inf) ? -1 : ans);
      |     ^~~~~~
cyberland.cpp:36:1: error: expected declaration before '}' token
   36 | }
      | ^