Submission #1122986

#TimeUsernameProblemLanguageResultExecution timeMemory
1122986I_FloPPed21Bosses (BOI16_bosses)C++20
Compilation error
0 ms0 KiB
#include <iostream> #include <vector> #include <queue> using namespace std; const int N=5e3+2; int n; //observatie generala costul e size-ul subtreeului vector<int>prioritate[N]; vector<int>adj[N]; void citeste() { cin>>n; for(int i=1;i<=n;i++) { int size; cin>>size; for(int indice=1;indice<=size;indice++) { int sef; cin>>sef; prioritate[sef].push_back(i); } } } long long dp[N]; int global=0; long long ans=1e12; void dfs(int nod,int p) { dp[nod]=1; for(auto u:adj[nod]) { if(u!=p) { dfs(u,nod); dp[nod]+=dp[u]; } } global+=dp[nod]; } void parcurge(int sef) { queue<int>q; q.push(sef); vector<bool>viz(n+1,0); viz[sef]=true; for(int i=1;i<=n;i++) { adj[i].clear(); } while(!q.empty()) { int nod=q.front(); for(auto u:prioritate[nod]) { if(viz[u]==false) { adj[u].push_back(nod); adj[nod].push_back(u); viz[u]=true; q.push(u); } } q.pop(); } global=0; dfs(sef,0); ans=min(ans,global); } void rezolva() { for(int i=1;i<=n;i++) { parcurge(i); } cout<<ans<<'\n'; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); citeste(); rezolva(); return 0; }

Compilation message (stderr)

bosses.cpp: In function 'void parcurge(int)':
bosses.cpp:68:12: error: no matching function for call to 'min(long long int&, int&)'
   68 |     ans=min(ans,global);
      |         ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from bosses.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
bosses.cpp:68:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   68 |     ans=min(ans,global);
      |         ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/char_traits.h:39,
                 from /usr/include/c++/11/ios:40,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from bosses.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
bosses.cpp:68:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   68 |     ans=min(ans,global);
      |         ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from bosses.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3449:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3449 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3449:5: note:   template argument deduction/substitution failed:
bosses.cpp:68:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   68 |     ans=min(ans,global);
      |         ~~~^~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/ostream:38,
                 from /usr/include/c++/11/iostream:39,
                 from bosses.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3455:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3455 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3455:5: note:   template argument deduction/substitution failed:
bosses.cpp:68:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   68 |     ans=min(ans,global);
      |         ~~~^~~~~~~~~~~~