Submission #979562

#TimeUsernameProblemLanguageResultExecution timeMemory
979562phoenix0423Cyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<ll, ll> pll; #define pb push_back #define eb emplace_back #define f first #define s second #include "cyberland.h" const int maxn = 2e5 + 5; const double INF = 1e18; const double eps = 1e-9; vector<pll> adj[maxn]; int vis[maxn]; double dist[maxn]; void dfs(int pos){ vis[pos] = 1; for(auto [x, w] : adj[pos]){ if(vis[x]) continue; dfs(x); } } struct info{ double d; int pos, l; info(){} info(double _d, int _pos) : d(_d), pos(_pos), l(_l){} bool operator < (const info& other) const{ return d < other.d; } bool operator > (const info& other) const{ return d > other.d; } }; priority_queue<info, vector<info>, greater<info>> q; 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) { k = min(k, 80); for(int i = 0; i < n; i++) adj[i].clear(), vis[i] = 0; for(int i = 0; i < m; i++){ adj[x[i]].pb({y[i], c[i]}); adj[y[i]].pb({x[i], c[i]}); } dfs(0); if(!vis[h]) return -1; for(int i = 1; i < n; i++) for(int j = 0; j <= k; j++) dist[i][j] = INF; arr[0] = 0; for(int i = 0; i < n; i++){ if(arr[i] == 0 && vis[i]){ for(int j = 0; j <= k; j++) dist[i][j] = 0; q.push(info(0, i, 0)); } } q.push(info(0, 0, 0)); while(!q.empty()){ auto [d, pos, l] = q.top(); q.pop(); if(dist[pos][l] < d || pos == h) continue; if(arr[pos] == 0 && l > 0) continue; if(arr[pos] == 0) dist[pos][l] = d = 0; for(auto [x, w] : adj[pos]){ if(dist[x][l] > d + w){ dist[x][l] = d + w; q.push(info(dist[x][l], x, l)); } } if(arr[pos] == 2 && l < k){ d /= 2, l++; if(dist[pos][l] < d) continue; for(auto [x, w] : adj[pos]){ if(dist[x][l] > d + w){ dist[x][l] = d + w; q.push(info(dist[x][l], x, l)); } } } } double ans = INF; for(int i = 0; i <= k; i++) dijk(); for(int i = 0; i <= k; i++) ans = min(ans, dist[h][i]); return ans; }

Compilation message (stderr)

cyberland.cpp: In constructor 'info::info(double, int)':
cyberland.cpp:29:53: error: '_l' was not declared in this scope; did you mean 'l'?
   29 |     info(double _d, int _pos) : d(_d), pos(_pos), l(_l){}
      |                                                     ^~
      |                                                     l
cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:49:67: error: invalid types 'double[int]' for array subscript
   49 |     for(int i = 1; i < n; i++) for(int j = 0; j <= k; j++) dist[i][j] = INF;
      |                                                                   ^
cyberland.cpp:53:48: error: invalid types 'double[int]' for array subscript
   53 |             for(int j = 0; j <= k; j++) dist[i][j] = 0;
      |                                                ^
cyberland.cpp:54:32: error: no matching function for call to 'info::info(int, int&, int)'
   54 |             q.push(info(0, i, 0));
      |                                ^
cyberland.cpp:29:5: note: candidate: 'info::info(double, int)'
   29 |     info(double _d, int _pos) : d(_d), pos(_pos), l(_l){}
      |     ^~~~
cyberland.cpp:29:5: note:   candidate expects 2 arguments, 3 provided
cyberland.cpp:28:5: note: candidate: 'info::info()'
   28 |     info(){}
      |     ^~~~
cyberland.cpp:28:5: note:   candidate expects 0 arguments, 3 provided
cyberland.cpp:25:8: note: candidate: 'constexpr info::info(const info&)'
   25 | struct info{
      |        ^~~~
cyberland.cpp:25:8: note:   candidate expects 1 argument, 3 provided
cyberland.cpp:25:8: note: candidate: 'constexpr info::info(info&&)'
cyberland.cpp:25:8: note:   candidate expects 1 argument, 3 provided
cyberland.cpp:57:24: error: no matching function for call to 'info::info(int, int, int)'
   57 |     q.push(info(0, 0, 0));
      |                        ^
cyberland.cpp:29:5: note: candidate: 'info::info(double, int)'
   29 |     info(double _d, int _pos) : d(_d), pos(_pos), l(_l){}
      |     ^~~~
cyberland.cpp:29:5: note:   candidate expects 2 arguments, 3 provided
cyberland.cpp:28:5: note: candidate: 'info::info()'
   28 |     info(){}
      |     ^~~~
cyberland.cpp:28:5: note:   candidate expects 0 arguments, 3 provided
cyberland.cpp:25:8: note: candidate: 'constexpr info::info(const info&)'
   25 | struct info{
      |        ^~~~
cyberland.cpp:25:8: note:   candidate expects 1 argument, 3 provided
cyberland.cpp:25:8: note: candidate: 'constexpr info::info(info&&)'
cyberland.cpp:25:8: note:   candidate expects 1 argument, 3 provided
cyberland.cpp:60:21: error: invalid types 'double[int]' for array subscript
   60 |         if(dist[pos][l] < d || pos == h) continue;
      |                     ^
cyberland.cpp:62:36: error: invalid types 'double[int]' for array subscript
   62 |         if(arr[pos] == 0) dist[pos][l] = d = 0;
      |                                    ^
cyberland.cpp:64:23: error: invalid types 'double[int]' for array subscript
   64 |             if(dist[x][l] > d + w){
      |                       ^
cyberland.cpp:65:24: error: invalid types 'double[int]' for array subscript
   65 |                 dist[x][l] = d + w;
      |                        ^
cyberland.cpp:66:36: error: invalid types 'double[int]' for array subscript
   66 |                 q.push(info(dist[x][l], x, l));
      |                                    ^
cyberland.cpp:71:25: error: invalid types 'double[int]' for array subscript
   71 |             if(dist[pos][l] < d) continue;
      |                         ^
cyberland.cpp:73:27: error: invalid types 'double[int]' for array subscript
   73 |                 if(dist[x][l] > d + w){
      |                           ^
cyberland.cpp:74:28: error: invalid types 'double[int]' for array subscript
   74 |                     dist[x][l] = d + w;
      |                            ^
cyberland.cpp:75:40: error: invalid types 'double[int]' for array subscript
   75 |                     q.push(info(dist[x][l], x, l));
      |                                        ^
cyberland.cpp:81:33: error: 'dijk' was not declared in this scope
   81 |     for(int i = 0; i <= k; i++) dijk();
      |                                 ^~~~
cyberland.cpp:82:55: error: invalid types 'double[int]' for array subscript
   82 |     for(int i = 0; i <= k; i++) ans = min(ans, dist[h][i]);
      |                                                       ^