Submission #862806

#TimeUsernameProblemLanguageResultExecution timeMemory
862806BerryisbetterCyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include "cyberland.h" #include <bits/stdc++.h> using namespace std; using ll = long double; using vll = vector<ll>; using vvll = vector<vll>; const ll INF = 1e16; vll v; vector<vector<pair<ll, ll>>>g; ll h,n; void dfs(ll x) { if (v[x]++) return; if ((int)x%(int)n==h) return; for (auto i : g[x]) { dfs(i.first); } } 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) { ll m = M, k = min(K, 0) + 1; h = H, n = N; v = vll(n * k); g = vector<vector<pair<ll, ll>>>(n * k); for (ll j = 0; j < k; j++) { for (ll i = 0; i < m; i++) { g[x[i] + j * n].push_back({ y[i] + j * n, c[i] * 1.0 / (1ll << (long long)j) }); g[y[i] + j * n].push_back({ x[i] + j * n, c[i] * 1.0 / (1ll << (long long)j) }); if (j && arr[x[i]] == 2) { g[x[i] + j * n].push_back({ y[i] + (j - 1) * n, c[i] * 1.0 / (1ll << (long long)j) }); } if (j && arr[y[i]] == 2) { g[y[i] + j * n].push_back({ x[i] + (j - 1) * n, c[i] * 1.0 / (1ll << (long long)j) }); } } } for (ll i = 0; i < k; i++) { dfs(i * n); } vll save = v; v = vll(n * k, INF); priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> q; for (ll i = 0; i < k; i++) { q.push({ 0,i*n }); v[i*n] = 0; } for (ll j = 0; j < k; j++) { for (ll i = 0; i < n; i++) { if (arr[i] == 0&&save[i+j*n]) { q.push({ 0, i + j * n }); v[i + j * n] = 0; } } } vll save = vll(n*k); while (q.size()) { ll ce= q.top().second; q.pop(); if ((int)ce%(int)n==h) { continue; } if (!save[ce]++) { for (auto i : g[ce]) { if (v[i.first] <= v[ce] + i.second) { continue; } v[i.first] = v[ce] + i.second; q.push({ v[i.first],i.first }); } } } return v[h]; }

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:51:6: error: redeclaration of 'vll save'
   51 |  vll save = vll(n*k);
      |      ^~~~
cyberland.cpp:36:6: note: 'vll save' previously declared here
   36 |  vll save = v;
      |      ^~~~