Submission #426158

# Submission time Handle Problem Language Result Execution time Memory
426158 2021-06-13T14:46:21 Z chirathnirodha Crocodile's Underground City (IOI11_crocodile) C++17
0 / 100
1 ms 204 KB
//Coded by Chirath Nirodha
#include "crocodile.h"
#include<bits/stdc++.h>
using namespace std;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define P push
typedef long long ll;

int travel_plan(int N, int M, int R[][2], int L[], int K, int P[]){
  vector<pair<ll,ll> > adj[N];
  for(int i=0;i<M;i++){
    adj[R[i][0]].PB(MP(R[i][1],L[i]));
    adj[R[i][1]].PB(MP(R[i][0],L[i]));
  }
  ll shortest[N][2];
  for(int i=0;i<N;i++)shortest[i][0]=shortest[i][1]=INT64_MAX;
  priority_queue<pair<ll,ll> > q;
  for(int i=0;i<K;i++){
    shortest[P[i]][0]=shortest[P[i]][1]=0;
    q.P(MP(0,P[i]));
  }
  while(!q.empty()){
    int c=q.top().S;q.pop();
    for(int i=0;i<adj[c].size();i++){
      int a=adj[c][i].F;
      ll len=adj[c][i].S;
      if(shortest[a][0]>shortest[c][1]+len){
        shortest[a][1]=shortest[a][0];
        shortest[a][0]=shortest[c][1]+len;
        q.P(MP(-shortest[a][1],a));
      }
      else if(shortest[a][1]>shortest[c][1]+len){
        shortest[a][1]=shortest[c][1]+len;
        q.P(MP(-shortest[a][1],a));
      }
    }
  }
  return shortest[0][1];
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:27:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   27 |     for(int i=0;i<adj[c].size();i++){
      |                 ~^~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -