Submission #258170

# Submission time Handle Problem Language Result Execution time Memory
258170 2020-08-05T13:34:12 Z monus1042 Crocodile's Underground City (IOI11_crocodile) C++17
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
#define pb push_back
#define mkp make_pair
#define all(X) X.begin(), X.end()

const int MAXS = 100002;
vector< pair<int, ll> > g[MAXS];
priority_queue < pair<ll, int>, vector< pair<ll, int>, greater< pair<ll,int> > > pq;
ll d[MAXS];
int state[MAXS]; // 0 unvisited, 1 has first val, 2 totally updated

void dj(){
  while(!pq.empty()){
    int auxu = pq.top().second;
    ll w = pq.top().first;
    pq.pop();
    for (int i=0; i<g[auxu].size(); i++){
      int v = g[auxu][i].first;
      ll wuv = g[auxu][i].second + w;
      if (state[v] == 2) continue;
      if (state[v] == 0){
	state[v]=1;
	d[v] = wuv;
	if (v != 0) pq.push(mkp(wuv, v));
      }
      if (state[v] == 1){
	state[v] = 2;
	d[v] = wuv;
	if (v != 0) pq.push(mkp(wuv, v));
      }
    }
  }
}

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

  for (int i=0; i<K; i++){
    pq.push(mkp(0, P[i]));
    d[P[i]]=0;
    state[P[i]]=2;
  }

  dj();
  return (int)d[0];
}

Compilation message

crocodile.cpp:14:82: error: template argument 2 is invalid
 priority_queue < pair<ll, int>, vector< pair<ll, int>, greater< pair<ll,int> > > pq;
                                                                                  ^~
crocodile.cpp:14:82: error: template argument 3 is invalid
crocodile.cpp: In function 'void dj()':
crocodile.cpp:19:10: error: 'pq' was not declared in this scope
   while(!pq.empty()){
          ^~
crocodile.cpp:19:10: note: suggested alternative: 'pb'
   while(!pq.empty()){
          ^~
          pb
crocodile.cpp:23:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i=0; i<g[auxu].size(); i++){
                   ~^~~~~~~~~~~~~~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:48:5: error: 'pq' was not declared in this scope
     pq.push(mkp(0, P[i]));
     ^~
crocodile.cpp:48:5: note: suggested alternative: 'pb'
     pq.push(mkp(0, P[i]));
     ^~
     pb