Submission #622579

# Submission time Handle Problem Language Result Execution time Memory
622579 2022-08-04T11:54:58 Z BhavayGoyal Crocodile's Underground City (IOI11_crocodile) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

template<class T> using oset = 
            tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define ld long double
#define ar array
#define vi vector<int>
#define vii vector<vector<int>>
#define pii pair<int, int>
#define pb push_back
#define all(x) x.begin(), x.end()
#define f first
#define s second
#define endl "\n"

const int MOD = 1e9+7;
const int inf = 1e9;
const int linf = 1e18;

const int d4i[4]={-1, 0, 1, 0}, d4j[4]={0, 1, 0, -1};
const int d8i[8]={-1, -1, 0, 1, 1, 1, 0, -1}, d8j[8]={0, 1, 1, 1, 0, -1, -1, -1};


// -------------------------------------------------- Main Code --------------------------------------------------

const int N = 1005;
vector<array<int, 2>> g[N];
vi temp[N];
int dis[N], vis[N];

void dfs(int src) {
    vis[src] = true;
    for (auto ch : g[src]) {
        int child = ch[0], wt = ch[1];
        if (!vis[child]) {
            dfs(child);
            temp[src].pb(dis[child]+wt);
            dis[src] = min(dis[src], dis[child] + wt);
        }
    }
    if (g[src].size() == 1) dis[src] = 0;
    else {
        sort (all(temp[src]));
        dis[src] = temp[src][1];
    }
}

int travel_plan(int n, int m, int **r, int* l, int k, int *p) {
    memset(dis, 63, sizeof dis);
    vii edges; 
    for (int i = 0; i < m; i++) edges.pb({r[i][0], r[i][1]});
    for (int i = 0; i < m; i++) edges[i].pb(l[i]);
    for (int i = 0; i < k; i++) {
        int x = p[i];
    }

    for (auto i : edges) {
        int a = i[0], b = i[1], c = i[2];
        g[a].pb({b, c});
        g[b].pb({a, c});
    }
    dfs(0);
    cout << dis[0] << endl;
}

Compilation message

crocodile.cpp: In function 'long long int travel_plan(long long int, long long int, long long int**, long long int*, long long int, long long int*)':
crocodile.cpp:61:13: warning: unused variable 'x' [-Wunused-variable]
   61 |         int x = p[i];
      |             ^
crocodile.cpp:71:1: warning: no return statement in function returning non-void [-Wreturn-type]
   71 | }
      | ^
/usr/bin/ld: /tmp/ccADCDLL.o: in function `main':
grader.cpp:(.text.startup+0x36): undefined reference to `travel_plan(int, int, int (*) [2], int*, int, int*)'
collect2: error: ld returned 1 exit status