Submission #842077

# Submission time Handle Problem Language Result Execution time Memory
842077 2023-09-02T11:16:49 Z TS_2392 Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "crocodile.h"

using namespace std;

#define fileIO(name) if(fopen(name".inp", "r")) {freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);}
#define SPEED        ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define EL           cout << '\n'
#define dbg(x)       cout << #x << " = " << (x) << ' '
#define dbgp(x)      cout << #x << " = (" << (x.fi) << ", " << (x.se) << ") "

#define epl          emplace
#define pb           push_back
#define eb           emplace_back
#define fi           first
#define se           second
#define mp           make_pair

#define sqr(x)       ((x) * (x))
#define all(x)       (x).begin(), (x).end()
#define rall(x)      (x).rbegin(), (x).rend()
#define lwb          lower_bound
#define upb          upper_bound
#define ctz          __builtin_ctzll
#define pct          __builtin_popcountll

typedef long long            ll;
typedef long double          ldb;
typedef unsigned int         uint;
typedef unsigned long long   ull;
typedef pair<ll, ll>         pll;
typedef pair<ll, int>        pli;
typedef pair<int, ll>        pil;
typedef pair<int, int>       pii;
typedef pair<ldb, ldb>       pld;
typedef pair<double, double> pdd;

template<class T1, class T2> bool minimize(T1 &a, T2 b){return a > b ? a = b, true : false;}
template<class T1, class T2> bool maximize(T1 &a, T2 b){return a < b ? a = b, true : false;}

int d4x[4] = {1, 0, -1, 0}, d8x[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int d4y[4] = {0, 1, 0, -1}, d8y[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//-----------------------------------------------------------------------//
const int N = 1e5 + 3, M = 1e6 + 3;
const ll oo = 1e17;
int n, m, k;// R[M][2], L[M], P[N];
vector<pii> adj[N];
pll d[N];
struct state{
    int vertex; pll di;
    bool operator < (const state &oth) const{
        return di.se > oth.di.se;
    }
};
priority_queue<state> pq;
int travel_plan(int N, int M, int R[][2], int L[], int K, int P){
    n = N, m = M, k = K;
    for(int i = 0; i < m; ++i){
        adj[R[i][0]].eb(R[i][1], L[i]);
        adj[R[i][1]].eb(R[i][0], L[i]);
    }
    for(int i = 0; i < n; ++i) d[i] = {oo, oo};
    for(int i = 0; i < k; ++i){
        d[P[i]] = {0, 0};
        pq.push({P[i], d[P[i]]});
    }
    while(!pq.empty()){
        int u = pq.top().vertex;
        pll dist = pq.top().di;
        pq.pop();
        if(dist != d[u]) continue;
        if(d[u].se == oo) break;
        for(int i = 0; i < adj[u].size(); ++i){
            int v = adj[u][i].fi;
            ll w = adj[u][i].se;
            if(d[v].fi > d[u].se + w){
                d[v].se = d[v].fi;
                d[v].fi = d[u].se + w;
                pq.push({v, d[v]});
            }
            else if(minimize(d[v].se, d[u].se + w)){
                pq.push({v, d[v]});
            }
        }
    }
    return d[0].se;
}

Compilation message

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int)':
crocodile.cpp:64:12: error: invalid types 'int[int]' for array subscript
   64 |         d[P[i]] = {0, 0};
      |            ^
crocodile.cpp:65:19: error: invalid types 'int[int]' for array subscript
   65 |         pq.push({P[i], d[P[i]]});
      |                   ^
crocodile.cpp:65:27: error: invalid types 'int[int]' for array subscript
   65 |         pq.push({P[i], d[P[i]]});
      |                           ^
crocodile.cpp:65:32: error: no matching function for call to 'std::priority_queue<state>::push(<brace-enclosed initializer list>)'
   65 |         pq.push({P[i], d[P[i]]});
      |                                ^
In file included from /usr/include/c++/10/queue:64,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86,
                 from crocodile.cpp:1:
/usr/include/c++/10/bits/stl_queue.h:640:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = state; _Sequence = std::vector<state, std::allocator<state> >; _Compare = std::less<state>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = state]'
  640 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:640:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const state&'}
  640 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_queue.h:648:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(std::priority_queue<_Tp, _Sequence, _Compare>::value_type&&) [with _Tp = state; _Sequence = std::vector<state, std::allocator<state> >; _Compare = std::less<state>; std::priority_queue<_Tp, _Sequence, _Compare>::value_type = state]'
  648 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/10/bits/stl_queue.h:648:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<state>::value_type&&' {aka 'state&&'}
  648 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
crocodile.cpp:73:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |         for(int i = 0; i < adj[u].size(); ++i){
      |                        ~~^~~~~~~~~~~~~~~