Submission #411264

#TimeUsernameProblemLanguageResultExecution timeMemory
411264LouayFarahCrocodile's Underground City (IOI11_crocodile)C++14
Compilation error
0 ms0 KiB
#include "bits/stdc++.h" #include "crocodile.h" using namespace std; #define fi first #define se second #define pb push_back #define mp make_pair void dfs(vector<pair<int, int>> tree[], vector<int> &parent, vector<int> &dist, vector<int> &len, int u, int e) { for(auto v: tree[u]) { if(v.fi==e) continue; parent[v.fi] = u; dist[v.fi] = dist[u] + v.se; len[v.fi] = len[u] + 1; dfs(tree, parent, dist, len, v.fi, u); } } void remove_subtree(vector<pair<int, int>> tree[], vector<bool> &erased, int u, int e) { erased[u] = true; for(auto v: tree[u]) if(v.fi!=e) remove_subtree(tree, erased, v.fi, u); } int travel_plan(int n, int m, int r[][2], int l[], int k, int p[]) { vector<pair<int, int>> tree[n]; for(int i = 0; i<m; i++) { tree[r[i][0]].pb(mp(r[i][1], l[i])); tree[r[i][1]].pb(mp(r[i][0], l[i])); } vector<int> dist(n, 0); vector<int> len(n, 0); vector<int> parent(n, -1); dfs(tree, parent, dist, len, 0, -1); vector<pair<pair<int, int>, int>> arr; for(int i = 0; i<k; i++) { arr.pb(mp(mp(dist[p[i]], len[p[i]]), p[i])); } sort(all(arr)); vector<bool> erased(n, false); int res = 0; /*for(int i = 0; i<k; i++) cout << arr[i].fi.fi << ' ' << arr[i].fi.se << ' ' << arr[i].se << endl;*/ sort(p, p+k); for(int i = 0; i<k; i++) { if(erased[arr[i].se]) continue; if(i+1<arr[i].fi.se) { remove_subtree(tree, erased, parent[arr[i].se], parent[parent[arr[i].se]]); } else if(i+1==arr[i].fi.se) { vector<int> temp; for(auto u: tree[parent[arr[i].se]]) { if(binary_search(p, p+k, u.fi)) temp.pb(dist[u.fi]); } if(temp.size()>1) { sort(all(temp)); res = temp[1]; break; } } else { res = arr[i].fi.fi; break; } } return res; }

Compilation message (stderr)

crocodile.cpp: In function 'int travel_plan(int, int, int (*)[2], int*, int, int*)':
crocodile.cpp:51:10: error: 'all' was not declared in this scope
   51 |     sort(all(arr));
      |          ^~~