Submission #1247923

#TimeUsernameProblemLanguageResultExecution timeMemory
1247923nekolie꿈 (IOI13_dreaming)C++20
Compilation error
0 ms0 KiB
// Fluixarata or Cyngulini? // That is the question... #include "dreaming.h" #include <bits/stdc++.h> using namespace std; void dfs(int v, int p, int dp[], bool odw[], vector<pair<int,int>> tree[], int &maks) { dp[v] = 0, odw[v] = true; int x = 0, y = 0; for (auto [u,w] : tree[v]) { if (u == p) continue; dfs(u,v,dp,odw,tree,maks), dp[v] = max(dp[v],dp[u]+w); if (dp[u]+w > x) y = x, x = dp[u]+w; else if (dp[u]+w > y) y = dp[u]+w; } maks = max(maks,x+y); } int travelTime(int n, int m, int l, int A[], int B[], int T[]) { bool odw[n+1]; fill(odw,odw[n+1],false); int dp[n+1], inf = (1<<30), x = -inf, y = -inf, z = -inf; vector<pair<int,int>> tree[n+1]; for (int i = 0; i < m; i++) tree[A[i]+1].push_back({B[i]+1,T[i]}), tree[B[i]+1].push_back({A[i]+1,T[i]}); for (int i = 1; i <= n; i++) { if (odw[i]) continue; int maks = 0; dfs(i,0,dp,odw,tree,maks); if (maks > x) z = y, y = x, x = maks; else if (maks > y) z = y, y = maks; else if (maks > z) z = maks; } return max({x,(x+1)/2+(y+1)/2+l,(y+1)/2+(z+1)/2+2*l}); }

Compilation message (stderr)

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:22:24: error: no matching function for call to 'fill(bool [(n + 1)], bool&, bool)'
   22 |     bool odw[n+1]; fill(odw,odw[n+1],false);
      |                    ~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from dreaming.cpp:4:
/usr/include/c++/11/bits/stl_algobase.h:992:5: note: candidate: 'template<class _ForwardIterator, class _Tp> constexpr void std::fill(_ForwardIterator, _ForwardIterator, const _Tp&)'
  992 |     fill(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value)
      |     ^~~~
/usr/include/c++/11/bits/stl_algobase.h:992:5: note:   template argument deduction/substitution failed:
dreaming.cpp:22:24: note:   deduced conflicting types for parameter '_ForwardIterator' ('bool*' and 'bool')
   22 |     bool odw[n+1]; fill(odw,odw[n+1],false);
      |                    ~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from dreaming.cpp:4:
/usr/include/c++/11/pstl/glue_algorithm_defs.h:191:1: note: candidate: 'template<class _ExecutionPolicy, class _ForwardIterator, class _Tp> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::fill(_ExecutionPolicy&&, _ForwardIterator, _ForwardIterator, const _Tp&)'
  191 | fill(_ExecutionPolicy&& __exec, _ForwardIterator __first, _ForwardIterator __last, const _Tp& __value);
      | ^~~~
/usr/include/c++/11/pstl/glue_algorithm_defs.h:191:1: note:   template argument deduction/substitution failed:
dreaming.cpp:22:24: note:   variable-sized array type 'bool (&)[(n + 1)]' is not a valid template argument
   22 |     bool odw[n+1]; fill(odw,odw[n+1],false);
      |                    ~~~~^~~~~~~~~~~~~~~~~~~~