Submission #426463

# Submission time Handle Problem Language Result Execution time Memory
426463 2021-06-14T04:33:15 Z Trickster Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
//Suleyman Atayew

#include "crocodile.h"
#include <algorithm>
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <vector>
#include <bitset>
#include <queue>
#include <cmath>
#include <map>
#include <set>
 
#define N 200010
#define ff first
#define ss second
#define pb push_back
#define ll long long
#define mod 1000000007
#define pii pair <int, int>
#define sz(a) (int)(a.size())
ll bigmod(ll a, ll b) { if(b==0)return 1; ll ret = bigmod(a, b/2); return ret * ret % mod * (b%2 ? a : 1) % mod; }

using namespace std;

int n, m, k;
int vis[N], dis[N];
vector <pii> E[N];
priority_queue <pii> Q;

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++) {
        int a = R[i][0], b = R[i][1], c = L[i];

        E[a].pb({b, c});
        E[b].pb({a, c});
    }
    
    for(int i = 0; i < n; i++) dis[i] = 1e9;

    for(int i = 0; i < k; i++) {
        int x = P[i];

        Q.push({0, x});
        vis[x] = 1, dis[x] = 0;
    }

    while(!Q.empty()) {
        int nd = Q.top().ff;
        Q.pop();

        if(vis[nd] == 2) continue;

        vis[nd]++;

        if(vis[nd] == 1) {
            dis[nd] = 1e9;
            continue;
        }
        for(auto i: E[nd]) {
            int to = i.ff;
            int w = i.ss;

            if(vis[to] == 2) continue;

            if(dis[to] > dis[nd]+w) {
                dis[to] = dis[nd]+w;
                Q.push({-dis[to], to});
            }
        }
    }

    return dis[n];
}

Compilation message

crocodile.cpp:15:11: error: expected ',' or '...' before numeric constant
   15 | #define N 200010
      |           ^~~~~~
crocodile.cpp:32:21: note: in expansion of macro 'N'
   32 | int travel_plan(int N, int M, int R[][2], int L[], int K, int P[])
      |                     ^
crocodile.cpp: In function 'int travel_plan(int)':
crocodile.cpp:34:16: error: 'M' was not declared in this scope
   34 |     n = N, m = M, k = K;
      |                ^
crocodile.cpp:34:23: error: 'K' was not declared in this scope
   34 |     n = N, m = M, k = K;
      |                       ^
crocodile.cpp:37:17: error: 'R' was not declared in this scope
   37 |         int a = R[i][0], b = R[i][1], c = L[i];
      |                 ^
crocodile.cpp:39:18: error: 'b' was not declared in this scope
   39 |         E[a].pb({b, c});
      |                  ^
crocodile.cpp:39:21: error: 'c' was not declared in this scope
   39 |         E[a].pb({b, c});
      |                     ^
crocodile.cpp:39:23: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   39 |         E[a].pb({b, c});
      |                       ^
In file included from /usr/include/c++/10/vector:67,
                 from crocodile.cpp:8:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
crocodile.cpp:46:17: error: 'P' was not declared in this scope
   46 |         int x = P[i];
      |                 ^