Submission #29490

# Submission time Handle Problem Language Result Execution time Memory
29490 2017-07-19T13:24:35 Z Nikefor Crocodile's Underground City (IOI11_crocodile) C++
Compilation error
0 ms 0 KB
#include "crocodile.h"
#include<bits/stdc++.h>
#define ii pair<int,int>
using namespace std;
int visit[100002];
int res;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
{
    priority_queue<ii, vector<int>, greater<int> > q;
    vector<ii> adj[N+2];
    for(int i=0; i<K; i++) q.push(make_pair(0,P[i]));
    while(!q.empty()) {
         ii e = q.top();
         int v = e.second;
         q.pop;
         if(!visit[v]) {
            visit++;
            continue;
         }
         visit++;
        if(!v){
            res = e.first;
            break;
        }
        for(int i=0; i<adj[v].size(); i++) {
            if(visit[adj[v].first]<2) q.push(make_pair(e.first+L[adj[v].second], adj[v].first ));
        }

    }





  return res;
}


Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:11:52: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<int>, std::greater<int> >::push(std::pair<int, int>)'
     for(int i=0; i<K; i++) q.push(make_pair(0,P[i]));
                                                    ^
In file included from /usr/include/c++/5/queue:64:0,
                 from /usr/include/x86_64-linux-gnu/c++/5/bits/stdc++.h:85,
                 from crocodile.cpp:2:
/usr/include/c++/5/bits/stl_queue.h:499:7: note: candidate: void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<int>; _Compare = std::greater<int>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = int]
       push(const value_type& __x)
       ^
/usr/include/c++/5/bits/stl_queue.h:499:7: note:   no known conversion for argument 1 from 'std::pair<int, int>' to 'const value_type& {aka const int&}'
crocodile.cpp:13:22: error: conversion from 'const int' to non-scalar type 'std::pair<int, int>' requested
          ii e = q.top();
                      ^
crocodile.cpp:15:15: error: invalid use of non-static member function
          q.pop;
               ^
crocodile.cpp:17:18: error: lvalue required as increment operand
             visit++;
                  ^
crocodile.cpp:20:15: error: lvalue required as increment operand
          visit++;
               ^
crocodile.cpp:25:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         for(int i=0; i<adj[v].size(); i++) {
                       ^
crocodile.cpp:26:29: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
             if(visit[adj[v].first]<2) q.push(make_pair(e.first+L[adj[v].second], adj[v].first ));
                             ^
crocodile.cpp:26:73: error: 'class std::vector<std::pair<int, int> >' has no member named 'second'
             if(visit[adj[v].first]<2) q.push(make_pair(e.first+L[adj[v].second], adj[v].first ));
                                                                         ^
crocodile.cpp:26:89: error: 'class std::vector<std::pair<int, int> >' has no member named 'first'
             if(visit[adj[v].first]<2) q.push(make_pair(e.first+L[adj[v].second], adj[v].first ));
                                                                                         ^