Submission #1296547

#TimeUsernameProblemLanguageResultExecution timeMemory
1296547LaMatematica14Dreaming (IOI13_dreaming)C++20
Compilation error
0 ms0 KiB
#include "dreaming.h" #include <bits/stdc++.h> using namespace std; 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:8:36: error: 'C' was not declared in this scope
    8 |         adj[A[i]].push_back({B[i], C[i]});
      |                                    ^
dreaming.cpp:8:28: error: no matching function for call to 'std::vector<std::pair<int, long long int> >::push_back(<brace-enclosed initializer list>)'
    8 |         adj[A[i]].push_back({B[i], C[i]});
      |         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
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,
                 from dreaming.cpp:2:
/usr/include/c++/13/bits/stl_vector.h:1281:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long long int>; _Alloc = std::allocator<std::pair<int, long long int> >; value_type = std::pair<int, long long int>]'
 1281 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1281:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long long int> >::value_type&' {aka 'const std::pair<int, long long int>&'}
 1281 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1298:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long long int>; _Alloc = std::allocator<std::pair<int, long long int> >; value_type = std::pair<int, long long int>]'
 1298 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1298:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long long int> >::value_type&&' {aka 'std::pair<int, long long int>&&'}
 1298 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
dreaming.cpp:9:28: error: no matching function for call to 'std::vector<std::pair<int, long long int> >::push_back(<brace-enclosed initializer list>)'
    9 |         adj[B[i]].push_back({A[i], C[i]});
      |         ~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1281:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, long long int>; _Alloc = std::allocator<std::pair<int, long long int> >; value_type = std::pair<int, long long int>]'
 1281 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1281:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::pair<int, long long int> >::value_type&' {aka 'const std::pair<int, long long int>&'}
 1281 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/13/bits/stl_vector.h:1298:7: note: candidate: 'constexpr void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::pair<int, long long int>; _Alloc = std::allocator<std::pair<int, long long int> >; value_type = std::pair<int, long long int>]'
 1298 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/13/bits/stl_vector.h:1298:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, long long int> >::value_type&&' {aka 'std::pair<int, long long int>&&'}
 1298 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
dreaming.cpp:12:25: error: expected unqualified-id before numeric constant
   12 |     vector<bool> vis(N. 0);
      |                         ^
dreaming.cpp:14:35: error: expected unqualified-id before '>' token
   14 |     vector<vector<long long, int>>> mxu(N);
      |                                   ^
dreaming.cpp: In lambda function:
dreaming.cpp:22:13: error: 'mxu' was not declared in this scope
   22 |             mxu[a].push_back({mxu[x.first][0].first+x.second, x.first});
      |             ^~~
dreaming.cpp:24:14: error: 'mxu' was not declared in this scope
   24 |         sort(mxu[a].rbegin(), mxu[a].rend());
      |              ^~~
dreaming.cpp: In lambda function:
dreaming.cpp:29:30: error: 'msu' was not declared in this scope
   29 |         long long best = max(msu[a][0].first, sum);
      |                              ^~~
dreaming.cpp:32:30: error: 'mxu' was not declared in this scope
   32 |             long long aus = (mxu[a][0].second == x.first) ? mxu[a][1].first : mxu[a][0].first;
      |                              ^~~