Submission #985393

#TimeUsernameProblemLanguageResultExecution timeMemory
985393ag_1204Cyberland (APIO23_cyberland)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; vector<pair<int,int>> graph[100001]; vector<vector<int>> edges; void add_edge(int u,int v,int w) { graph[u].push_back({v,w}); graph[v].push_back({u,w}); edges.push_back({u,v,w}); } vector<int> dijsktras(int src, int N) { vector<int> dis(N, INT_MAX); vector<bool> vis(N, false); priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq; pq.push({0,src}); dis[src] = 0; while (!pq.empty()) { auto cur = pq.top(); pq.pop(); int node = cur.second; int weight = cur.first; if (vis[node]) continue; vis[node] = true; for (auto child : graph[node]) { if (dis[child.first] > child.second + weight) { dis[child.first] = weight + child.second; pq.push({dis[child.first], child.first}); } } } return dis; } 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) { int N,M,K; cin>>N>>M>>K; int H; cin>>H; vector<int> arr(N),x(M),y(M),c(M); for (int i=0;i<N;i++) { cin>>arr[i]; } for (int i=0;i<M;i++) { cin>>x[i]; } for (int i=0;i<M;i++) { cin>>y[i]; } for (int i=0;i<M;i++) { cin>>c[i]; add_edge(x[i],y[i],c[i]); } vector<int> disA = dijsktras(0, N); double ans = disA[H]; for (int i=0;i<100001;i++) { graph[i].clear(); } return 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:38:9: error: declaration of 'int N' shadows a parameter
   38 |     int N,M,K; cin>>N>>M>>K;
      |         ^
cyberland.cpp:37:18: note: 'int N' previously declared here
   37 | 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) {
      |              ~~~~^
cyberland.cpp:38:11: error: declaration of 'int M' shadows a parameter
   38 |     int N,M,K; cin>>N>>M>>K;
      |           ^
cyberland.cpp:37:25: note: 'int M' previously declared here
   37 | 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) {
      |                     ~~~~^
cyberland.cpp:38:13: error: declaration of 'int K' shadows a parameter
   38 |     int N,M,K; cin>>N>>M>>K;
      |             ^
cyberland.cpp:37:32: note: 'int K' previously declared here
   37 | 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) {
      |                            ~~~~^
cyberland.cpp:39:9: error: declaration of 'int H' shadows a parameter
   39 |     int H; cin>>H;
      |         ^
cyberland.cpp:37:39: note: 'int H' previously declared here
   37 | 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) {
      |                                   ~~~~^
cyberland.cpp:40:17: error: declaration of 'std::vector<int> arr' shadows a parameter
   40 |     vector<int> arr(N),x(M),y(M),c(M);
      |                 ^~~
cyberland.cpp:37:119: note: 'std::vector<int> arr' previously declared here
   37 | 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) {
      |                                                                                                      ~~~~~~~~~~~~~~~~~^~~
cyberland.cpp:40:24: error: declaration of 'std::vector<int> x' shadows a parameter
   40 |     vector<int> arr(N),x(M),y(M),c(M);
      |                        ^
cyberland.cpp:37:59: note: 'std::vector<int> x' previously declared here
   37 | 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) {
      |                                          ~~~~~~~~~~~~~~~~~^
cyberland.cpp:40:29: error: declaration of 'std::vector<int> y' shadows a parameter
   40 |     vector<int> arr(N),x(M),y(M),c(M);
      |                             ^
cyberland.cpp:37:79: note: 'std::vector<int> y' previously declared here
   37 | 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) {
      |                                                              ~~~~~~~~~~~~~~~~~^
cyberland.cpp:40:34: error: declaration of 'std::vector<int> c' shadows a parameter
   40 |     vector<int> arr(N),x(M),y(M),c(M);
      |                                  ^
cyberland.cpp:37:99: note: 'std::vector<int> c' previously declared here
   37 | 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) {
      |                                                                                  ~~~~~~~~~~~~~~~~~^