Submission #1333753

#TimeUsernameProblemLanguageResultExecution timeMemory
1333753AquariusCrocodile's Underground City (IOI11_crocodile)C++20
Compilation error
0 ms0 KiB
/**
 *     Author: Lưu Diệp Thành (Save Diệp Thành)
 *     Le Hong Phong High School for the Gifted (i2528)
**/
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ushort unsigned short
#define FOR(i,l,r) for(int i = (l), _r = (r); i <= _r; i++)
#define FORN(i,r,l) for(int i = (r), _l = (l); i >= _l; i--)
#define endl '\n'
#define sz(x) (int)x.size()
#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define MASK(x) (1LL << (x))
#define BIT(x,i) (((x) >> (i)) & 1)
#define ins insert
#define segleft (id<<1)
#define segright (id<<1|1)
#define TIME  (1.0 * clock() / CLOCKS_PER_SEC)
const int MOD = 1e9+7;
const int INF = 1e9+7;

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) {
    vector<pair<int,int>> edge[n];
    FOR(i, 0, m-1) {
        edge[r[i][0]].pb({r[i][1], l[i]});
        edge[r[i][1]].pb({r[i][0], l[i]});
    }

    vector<pair<int,int>> dist(n, {INF, INF});
    priority_queue<pair<int,int>, vector<pair<int,int>>, greater<pair<int,int>>> q;
    FOR(i, 0, k-1) {
        q.push({0, p[i]});
        dist[p[i]] = {0,0};
    }

    while(!q.empty()) {
        auto[du, u] = q.top(); q.pop();
        if (du > dist[u].se) continue;

        for(auto[v,w] : edge[u]) {
            if (dist[v].fi > du + w) {
                dist[v].se = dist[v].fi;
                dist[v].fi = du + w;
                
                q.push({dist[v].se, v});
                }
            } else if (dist[v].se > du + w) {
                dist[v].se = du + w;
                q.push({dist[v].se, v});
            }
        }
    }

    return dist[0].se;
}

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:51:15: error: 'else' without a previous 'if'
   51 |             } else if (dist[v].se > du + w) {
      |               ^~~~
crocodile.cpp:51:29: error: 'v' was not declared in this scope
   51 |             } else if (dist[v].se > du + w) {
      |                             ^
crocodile.cpp:51:42: error: 'w' was not declared in this scope
   51 |             } else if (dist[v].se > du + w) {
      |                                          ^
crocodile.cpp:53:23: error: no matching function for call to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::push(<brace-enclosed initializer list>)'
   53 |                 q.push({dist[v].se, v});
      |                 ~~~~~~^~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/13/queue:66,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:157,
                 from crocodile.cpp:5:
/usr/include/c++/13/bits/stl_queue.h:738:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(const value_type&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; value_type = std::pair<int, int>]'
  738 |       push(const value_type& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:738:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::value_type&' {aka 'const std::pair<int, int>&'}
  738 |       push(const value_type& __x)
      |            ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_queue.h:746:7: note: candidate: 'void std::priority_queue<_Tp, _Sequence, _Compare>::push(value_type&&) [with _Tp = std::pair<int, int>; _Sequence = std::vector<std::pair<int, int> >; _Compare = std::greater<std::pair<int, int> >; value_type = std::pair<int, int>]'
  746 |       push(value_type&& __x)
      |       ^~~~
/usr/include/c++/13/bits/stl_queue.h:746:25: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int> >, std::greater<std::pair<int, int> > >::value_type&&' {aka 'std::pair<int, int>&&'}
  746 |       push(value_type&& __x)
      |            ~~~~~~~~~~~~~^~~
crocodile.cpp:56:5: warning: no return statement in function returning non-void [-Wreturn-type]
   56 |     }
      |     ^
crocodile.cpp: At global scope:
crocodile.cpp:58:5: error: expected unqualified-id before 'return'
   58 |     return dist[0].se;
      |     ^~~~~~
crocodile.cpp:59:1: error: expected declaration before '}' token
   59 | }
      | ^