Submission #530988

#TimeUsernameProblemLanguageResultExecution timeMemory
530988mat50013Crocodile's Underground City (IOI11_crocodile)C++11
Compilation error
0 ms0 KiB
#include "crocodile.h"
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
vector<pair<int, int> > G[MAX_N + 5];
ll dist[MAX_N + 5];
bool waiting[MAX_N + 5], viz[MAX_N + 5];
bool cmp(pair<int, int> a, pair<int, int> b)
{
    return (dist[a.first] + a.second) < (dist[b.first] + b.second);
}
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]].push_back({R[i][1], L[i]}), G[R[i][1]].push_back({R[i][0], L[i]});
    for(int i = 0; i < N; ++i)
        dist[i] = LLONG_MAX / 2;
    queue<int> q;
    for(int i = 0; i < K; ++i)
    {
        dist[P[i]] = 0;
        q.push(P[i]);
    }
    while(!q.empty())
    {
        int nd = q.front();
        q.pop();
        waiting[nd] = 0;
        for(auto it: G[nd])
            if(dist[nd] + it.second < dist[it.first])
            {
                dist[it.first] = dist[nd] + it.second;
                if(!waiting[it.first])
                {
                    q.push(it.first);
                    waiting[it.first] = 1;
                }
            }
    }
    int timp = 0, curNd = 0;
    viz[curNd] = 1;
    while(dist[curNd] != 0)
    {
        sort(G[curNd].begin(), G[curNd].end(), cmp);
        for(int i = 1; i < (G[curNd].size()); ++i)
            if(!viz[G[curNd][i].first])
            {
                timp += G[curNd][i].second;
                curNd = G[curNd][i].first;
                viz[curNd] = 1;
                break;
            }
    }
    return timp;
}

Compilation message (stderr)

crocodile.cpp:6:27: error: 'MAX_N' was not declared in this scope
    6 | vector<pair<int, int> > G[MAX_N + 5];
      |                           ^~~~~
crocodile.cpp:7:9: error: 'MAX_N' was not declared in this scope
    7 | ll dist[MAX_N + 5];
      |         ^~~~~
crocodile.cpp:8:14: error: 'MAX_N' was not declared in this scope
    8 | bool waiting[MAX_N + 5], viz[MAX_N + 5];
      |              ^~~~~
crocodile.cpp:8:30: error: 'MAX_N' was not declared in this scope
    8 | bool waiting[MAX_N + 5], viz[MAX_N + 5];
      |                              ^~~~~
crocodile.cpp: In function 'bool cmp(std::pair<int, int>, std::pair<int, int>)':
crocodile.cpp:11:13: error: 'dist' was not declared in this scope
   11 |     return (dist[a.first] + a.second) < (dist[b.first] + b.second);
      |             ^~~~
crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:16:9: error: 'G' was not declared in this scope
   16 |         G[R[i][0]].push_back({R[i][1], L[i]}), G[R[i][1]].push_back({R[i][0], L[i]});
      |         ^
crocodile.cpp:18:9: error: 'dist' was not declared in this scope
   18 |         dist[i] = LLONG_MAX / 2;
      |         ^~~~
crocodile.cpp:22:9: error: 'dist' was not declared in this scope
   22 |         dist[P[i]] = 0;
      |         ^~~~
crocodile.cpp:29:9: error: 'waiting' was not declared in this scope
   29 |         waiting[nd] = 0;
      |         ^~~~~~~
crocodile.cpp:30:22: error: 'G' was not declared in this scope
   30 |         for(auto it: G[nd])
      |                      ^
crocodile.cpp:31:16: error: 'dist' was not declared in this scope
   31 |             if(dist[nd] + it.second < dist[it.first])
      |                ^~~~
crocodile.cpp:42:5: error: 'viz' was not declared in this scope
   42 |     viz[curNd] = 1;
      |     ^~~
crocodile.cpp:43:11: error: 'dist' was not declared in this scope
   43 |     while(dist[curNd] != 0)
      |           ^~~~
crocodile.cpp:45:14: error: 'G' was not declared in this scope
   45 |         sort(G[curNd].begin(), G[curNd].end(), cmp);
      |              ^