Submission #419443

# Submission time Handle Problem Language Result Execution time Memory
419443 2021-06-07T06:42:32 Z snasibov05 Crocodile's Underground City (IOI11_crocodile) C++14
0 / 100
1 ms 204 KB
#include "crocodile.h"
#include <vector>
#include <algorithm>

using namespace std;

#define pb push_back
#define pii pair<int, int>
#define f first;
#define s second;
#define oo 1000000000

vector<vector<pii>> ed;
vector<bool> ext;

int ans = oo;

void dfs(int v, int pr, int d){
    vector<int> cur;
    for (auto [x, l] : ed[v]){
        if (x == pr) continue;
        if (ext[x]) cur.pb(d + l);
        else dfs(x, v, d + l);
    }

    if (cur.size() <= 1) return;
    sort(cur.begin(), cur.end());
    ans = min(ans, cur[1]);
}

int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]){

    ed.resize(n);
    ext.resize(n);

    for (int i = 0; i < m; ++i) {
        ed[r[i][0]].pb({r[i][1], l[i]});
        ed[r[i][1]].pb({r[i][0], l[i]});
    }

    for (int i = 0; i < k; ++i) {
        ext[p[i]] = true;
    }

    dfs(0, -1, 0);

    return ans;

}


Compilation message

crocodile.cpp: In function 'void dfs(int, int, int)':
crocodile.cpp:20:15: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   20 |     for (auto [x, l] : ed[v]){
      |               ^
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -