Submission #1296541

#TimeUsernameProblemLanguageResultExecution timeMemory
1296541LaMatematica14Dreaming (IOI13_dreaming)C++20
Compilation error
0 ms0 KiB
#include "dreaming.h" #include <bits/stdc++.h> int travelTime(int N, int M, int L, int A[], int B[], int T[]) { vector<vector<pair<int, long long>>> adj(N); for (int i = 0; i < M; i++) { adj[A[i]].push_back({B[i], C[i]}); adj[B[i]].push_back({A[i], C[i]}); } vector<bool> vis(N. 0); vector<long long> depth(N); vector<vector<long long, int>>> mxu(N); function<void(int, int, vector<int> &)> dfs = [&](int a, int p, vector<int> &curr) { vis[a] = 1; for (auto x : adj[a]) { if (x.first == p) continue; depth[x.first] = depth[a]+x.second; dfs(x.first, a, curr); mxu[a].push_back({mxu[x.first][0].first+x.second, x.first}); } sort(mxu[a].rbegin(), mxu[a].rend()); mxu[a].push_back({0, -1}); curr.push_back(a); }; function<long long(int, int, long long)> agg = [&](int a, int p, long long sum) -> long long { long long best = max(msu[a][0].first, sum); for (auto x : adj[a]) { if (x.first == p) continue; long long aus = (mxu[a][0].second == x.first) ? mxu[a][1].first : mxu[a][0].first; aus = max(aus, best)+x.second; best = min(best, agg(x.first, a, aus)); } return best; }; vector<long long> md; long long f = 0; for (int i = 0; i < N; i++) { if (vis[i]) continue; depth[i] = 0; vector<int> r; dfs(i, -1, r); md.push_back(agg(i, -1, 0)); int dm = i; for (int x : r) { if (depth[dm] < depth[x]) dm = x; } r.clear(); depth[dm] = 0; dfs(dm, -1, r); for (int x : r) { if (depth[dm] < depth[x]) dm = x; } f = max(depth[dm], f); } sort(md.rbegin(), md.rend()); if (md.size() > 1) f = max(f, md[0]+md[1]+L); if (md.size() > 2) f = max(f, md[1]+md[2]+2*L); return f; }

Compilation message (stderr)

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:5:19: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    5 |     vector<vector<pair<int, long long>>> adj(N);
      |                   ^~~~
      |                   std::pair
In file included from /usr/include/c++/13/bits/stl_algobase.h:64,
                 from /usr/include/c++/13/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from dreaming.cpp:2:
/usr/include/c++/13/bits/stl_pair.h:187:12: note: 'std::pair' declared here
  187 |     struct pair
      |            ^~~~
dreaming.cpp:5:12: error: 'vector' was not declared in this scope
    5 |     vector<vector<pair<int, long long>>> adj(N);
      |            ^~~~~~
dreaming.cpp:5:12: note: suggested alternatives:
In file included from /usr/include/c++/13/vector:66,
                 from /usr/include/c++/13/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:53:
/usr/include/c++/13/bits/stl_vector.h:428:11: note:   'std::vector'
  428 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
/usr/include/c++/13/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
dreaming.cpp:5:24: error: expected primary-expression before 'int'
    5 |     vector<vector<pair<int, long long>>> adj(N);
      |                        ^~~
dreaming.cpp:7:9: error: 'adj' was not declared in this scope
    7 |         adj[A[i]].push_back({B[i], C[i]});
      |         ^~~
dreaming.cpp:7:36: error: 'C' was not declared in this scope
    7 |         adj[A[i]].push_back({B[i], C[i]});
      |                                    ^
dreaming.cpp:11:12: error: expected primary-expression before 'bool'
   11 |     vector<bool> vis(N. 0);
      |            ^~~~
dreaming.cpp:12:12: error: expected primary-expression before 'long'
   12 |     vector<long long> depth(N);
      |            ^~~~
dreaming.cpp:13:19: error: expected primary-expression before 'long'
   13 |     vector<vector<long long, int>>> mxu(N);
      |                   ^~~~
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
   15 |     function<void(int, int, vector<int> &)> dfs = [&](int a, int p, vector<int> &curr) {
      |                                          ^
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
dreaming.cpp:15:5: error: 'function' was not declared in this scope; did you mean 'std::function'?
   15 |     function<void(int, int, vector<int> &)> dfs = [&](int a, int p, vector<int> &curr) {
      |     ^~~~~~~~
      |     std::function
In file included from /usr/include/c++/13/functional:59:
/usr/include/c++/13/bits/std_function.h:111:11: note: 'std::function' declared here
  111 |     class function;
      |           ^~~~~~~~
dreaming.cpp:15:42: error: expression list treated as compound expression in functional cast [-fpermissive]
   15 |     function<void(int, int, vector<int> &)> dfs = [&](int a, int p, vector<int> &curr) {
      |                                          ^
dreaming.cpp:15:14: error: expected primary-expression before 'void'
   15 |     function<void(int, int, vector<int> &)> dfs = [&](int a, int p, vector<int> &curr) {
      |              ^~~~
dreaming.cpp:27:14: error: expected primary-expression before 'long'
   27 |     function<long long(int, int, long long)> agg = [&](int a, int p, long long sum) -> long long {
      |              ^~~~
dreaming.cpp:38:12: error: expected primary-expression before 'long'
   38 |     vector<long long> md;
      |            ^~~~
dreaming.cpp:41:13: error: 'vis' was not declared in this scope
   41 |         if (vis[i]) continue;
      |             ^~~
dreaming.cpp:42:9: error: 'depth' was not declared in this scope
   42 |         depth[i] = 0;
      |         ^~~~~
dreaming.cpp:43:16: error: expected primary-expression before 'int'
   43 |         vector<int> r;
      |                ^~~
dreaming.cpp:44:20: error: 'r' was not declared in this scope
   44 |         dfs(i, -1, r);
      |                    ^
dreaming.cpp:44:9: error: 'dfs' was not declared in this scope; did you mean 'ffs'?
   44 |         dfs(i, -1, r);
      |         ^~~
      |         ffs
dreaming.cpp:45:9: error: 'md' was not declared in this scope
   45 |         md.push_back(agg(i, -1, 0));
      |         ^~
dreaming.cpp:45:22: error: 'agg' was not declared in this scope
   45 |         md.push_back(agg(i, -1, 0));
      |                      ^~~
dreaming.cpp:56:13: error: 'max' was not declared in this scope
   56 |         f = max(depth[dm], f);
      |             ^~~
dreaming.cpp:56:13: note: suggested alternatives:
In file included from /usr/include/c++/13/algorithm:61:
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   'std::max'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
In file included from /usr/include/c++/13/algorithm:63:
/usr/include/c++/13/bits/ranges_algo.h:2928:29: note:   'std::ranges::max'
 2928 |   inline constexpr __max_fn max{};
      |                             ^~~
dreaming.cpp:59:10: error: 'md' was not declared in this scope
   59 |     sort(md.rbegin(), md.rend());
      |          ^~
dreaming.cpp:59:5: error: 'sort' was not declared in this scope
   59 |     sort(md.rbegin(), md.rend());
      |     ^~~~
dreaming.cpp:59:5: note: suggested alternatives:
In file included from /usr/include/c++/13/algorithm:73:
/usr/include/c++/13/pstl/glue_algorithm_defs.h:296:1: note:   'std::sort'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/13/bits/ranges_algo.h:1801:30: note:   'std::ranges::sort'
 1801 |   inline constexpr __sort_fn sort{};
      |                              ^~~~
dreaming.cpp:60:28: error: 'max' was not declared in this scope
   60 |     if (md.size() > 1) f = max(f, md[0]+md[1]+L);
      |                            ^~~
dreaming.cpp:60:28: note: suggested alternatives:
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   'std::max'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/ranges_algo.h:2928:29: note:   'std::ranges::max'
 2928 |   inline constexpr __max_fn max{};
      |                             ^~~
dreaming.cpp:61:28: error: 'max' was not declared in this scope
   61 |     if (md.size() > 2) f = max(f, md[1]+md[2]+2*L);
      |                            ^~~
dreaming.cpp:61:28: note: suggested alternatives:
/usr/include/c++/13/bits/stl_algo.h:5805:5: note:   'std::max'
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/13/bits/ranges_algo.h:2928:29: note:   'std::ranges::max'
 2928 |   inline constexpr __max_fn max{};
      |                             ^~~