Submission #897787

# Submission time Handle Problem Language Result Execution time Memory
897787 2024-01-03T16:55:39 Z Trumling Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
1 ms 4440 KB
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
    
typedef long long ll;
#define pb push_back
#define F first
#define S second
#define enter cout<<'\n';
#define INF 9999999999999999
#define MOD 1000000007
#define round fixed<<setprecision(2)<<

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
  vector<vector<pair<ll,ll>>>g(N+1);
  for(int i=0;i<M;i++)
  {
    g[R[i][0]].pb({R[i][1],L[i]});
    g[R[i][1]].pb({R[i][0],L[i]});
  }

  priority_queue<pair<ll,ll>>pq;
  vector<pair<ll,ll>>dist(N+1,{INF,INF});
  for(int i=0;i<K;i++)
  {
    dist[P[i]]={0,0};
    pq.push({0,P[i]});
  }

  while(!pq.empty())
  {
    ll curr=pq.top().S;
    ll w=-pq.top().F;
    pq.pop();

    if(dist[curr].S<w)
    continue;

    for(auto x:g[curr])
    {
      if(dist[x.F].F> w + x.S)
      {
        
      if(dist[x.F].F!=INF)
        swap(dist[x.F].F,dist[x.F].S);
        
        dist[x.F].F=w + x.S;
        pq.push({-dist[x.F].F,x.F});
        continue;
      }

      if(dist[x.F].S> w + x.S)
      {
        dist[x.F].S=w + x.S;
        pq.push({-dist[x.F].S,x.F});
      }

    }
  }
  return dist[0].S;
    
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:45:7: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   45 |       if(dist[x.F].F!=INF)
      |       ^~
crocodile.cpp:48:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   48 |         dist[x.F].F=w + x.S;
      |         ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4440 KB Output isn't correct
2 Halted 0 ms 0 KB -