Submission #1253920

#TimeUsernameProblemLanguageResultExecution timeMemory
1253920anfiCyberland (APIO23_cyberland)C++20
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define fi first #define se second 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){ double ans = 1e18; K = min(K, 100); vector<pair<int,int>> adj[N]; vector<int> dp(N, inf), tmp(N, 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]}); } priority_queue<pair<double, int>> pq; dp[0] = 0.0; while(!pq.empty()){ auto [c, u] = pq.top(); pq.pop(); if(c > dp[u]) continue; for(auto &[v, w] : adj[u]){ double cost = c+w; if(dp[v] > cost){ dp[v] = cost; pq.push({dp[v], v}); } if(a[u] == 2 && pos < K){ double co = (c+w)/2.0; if(dp[v] > co){ dp[v] = co; pq.push({co, v}); } } } } for(int i = 0; i <= K; i++) ans = min(ans, dp[H][i]); return (ans >= inf/2 ? -1.0 : }

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:11:23: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   11 |     vector<int> dp(N, inf), tmp(N, inf)
      |                       ^~~
cyberland.cpp:11:36: warning: overflow in conversion from 'double' to 'std::vector<int>::value_type' {aka 'int'} changes value from '1.0e+18' to '2147483647' [-Woverflow]
   11 |     vector<int> dp(N, inf), tmp(N, inf)
      |                                    ^~~
cyberland.cpp:12:5: error: expected ',' or ';' before 'for'
   12 |     for(int i = 0;i < M; i++){
      |     ^~~
cyberland.cpp:12:19: error: 'i' was not declared in this scope
   12 |     for(int i = 0;i < M; i++){
      |                   ^
cyberland.cpp:27:16: error: 'a' was not declared in this scope
   27 |             if(a[u] == 2 && pos < K){
      |                ^
cyberland.cpp:27:29: error: 'pos' was not declared in this scope; did you mean 'pow'?
   27 |             if(a[u] == 2 && pos < K){
      |                             ^~~
      |                             pow
cyberland.cpp:36:53: error: invalid types '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type {aka int}[int]' for array subscript
   36 |     for(int i = 0; i <= K; i++) ans = min(ans, dp[H][i]);
      |                                                     ^
cyberland.cpp:37:35: error: expected primary-expression before '}' token
   37 |     return (ans >= inf/2 ? -1.0 : }
      |                                   ^
cyberland.cpp:37:34: error: expected ')' before '}' token
   37 |     return (ans >= inf/2 ? -1.0 : }
      |            ~                     ^~
      |                                  )
cyberland.cpp:37:34: error: expected ';' before '}' token
   37 |     return (ans >= inf/2 ? -1.0 : }
      |                                  ^~
      |                                  ;