Submission #954865

# Submission time Handle Problem Language Result Execution time Memory
954865 2024-03-28T18:17:15 Z ramalzaher Cyberland (APIO23_cyberland) C++17
0 / 100
26 ms 7516 KB
#include "cyberland.h"
#include<bits/stdc++.h>
using namespace std ;

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) {
long long dis[N+4] , vis[N+4] , p[N+4] ;
vector<pair<long long ,long long > > v[N+4] ;
for(long long  i = 0; i < M ; i ++ ){

    v[x[i]].push_back({y[i] , c[i] }) ;
    v[y[i]].push_back({x[i] , c[i] }) ;
}
     for(long long  i = 0 ; i < N + 2 ; i ++ ) {dis[i] = 1e14 ;p[i] = -1; vis[i] = 0; }
 priority_queue<pair<long long ,long long >   , vector<pair<long long ,long long >  >, greater<pair<long long ,long long >    > > q;
   q.push({0 ,1 });dis[1] = 0 ;
   while(q.size()){
      long long  top = q.top().second ;
      q.pop() ; long long  node = top   ;
      if(vis[node])continue ;vis[node] =1 ;
      for(auto it : v[top]){
         if(it.second + dis[top] <= dis[it.first]){
            p[it.first] = top ;
            dis[it.first] = it.second+dis[top] ;
            q.push({dis[it.first] , it.first});
         }
      }
   }
    long long  ans = dis[H] ;
    if(ans >= 1e14 ){ans = -1 ;}
    return ans;
}

Compilation message

cyberland.cpp: In function 'double solve(int, int, int, int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
cyberland.cpp:19:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   19 |       if(vis[node])continue ;vis[node] =1 ;
      |       ^~
cyberland.cpp:19:30: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   19 |       if(vis[node])continue ;vis[node] =1 ;
      |                              ^~~
cyberland.cpp:6:33: warning: variable 'p' set but not used [-Wunused-but-set-variable]
    6 | long long dis[N+4] , vis[N+4] , p[N+4] ;
      |                                 ^
# Verdict Execution time Memory Grader output
1 Incorrect 13 ms 348 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 604 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 344 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 23 ms 7516 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 22 ms 600 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 600 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 600 KB Wrong Answer.
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 600 KB Wrong Answer.
2 Halted 0 ms 0 KB -