Submission #290266

#TimeUsernameProblemLanguageResultExecution timeMemory
290266MasterTasterBosses (BOI16_bosses)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define ll long long #define pb push_back #define pii pair<int, int> #define xx first #define yy second #define endl "\n" vector<int> g[15], p[15]; int n, k[15], koga[15], trRess; //bool bio[15]; int ress; int d[5010]; map<int, bool> bio; int dfs(int u) { bio[u]=true; //cout<<u<<endl; int suma=0; for (auto v:g[u]) { if (!bio[v]) { suma+=dfs(v); } } trRess+=suma+1; return (suma)+1; } void popravi() { int koliko=0, root=-1; for (int i=1; i<=n; i++) { if (koga[i]==-1) { koliko++; root=i; } } if (koliko!=1) return; for (int i=1; i<=n; i++) { g[i].clear(); bio[i]=false; } for (int i=1; i<=n; i++) { if (i!=root) g[koga[i]].pb(i); } trRess=0; dfs(root); for (int i=1; i<=n; i++) if (!bio[i]) return; //for (int i=1; i<=n; i++) cout<<koga[i]<<" "; //cout<<endl<<trRess<<endl; ress=min(ress, trRess); } void uradi(int x, bool bio) { if (x==n+1) { popravi(); return; } if (!bio) { koga[x]=-1; uradi(x+1, true); } for (int i=0; i<k[x]; i++) { koga[x]=p[x][i]; uradi(x+1, bio); } } ll bfs(int s) { queue<int> q; q.push(s); d[s]=1; bio[s]=true; while (!q.empty()) { int u=q.front(); q.pop(); for (auto v:g[u]) { if (!bio[v]) { d[v]=d[u]+1; bio[v]=true; q.push(v); } } } ll ret=0; for (int i=1; i<=n; i++) ret+=d[i]; return ret; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cin>>n; for (int i=1; i<=n; i++) { cin>>k[i]; for (int j=0; j<k[i]; j++) { int x; cin>>x; g[x].pb(i); } } //ress=1010; //uradi(1, 0); ress=10000000000000010; for (int i=1; i<=n; i++) { bio.clear(); ll trRess=bfs(i); //cout<<trRess<<endl; ress=min(ress, trRess); } cout<<ress; }

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:119:10: warning: overflow in conversion from 'long int' to 'int' changes value from '10000000000000010' to '1874919434' [-Woverflow]
  119 |     ress=10000000000000010;
      |          ^~~~~~~~~~~~~~~~~
bosses.cpp:125:30: error: no matching function for call to 'min(int&, long long int&)'
  125 |         ress=min(ress, trRess);
      |                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from bosses.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
bosses.cpp:125:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  125 |         ress=min(ress, trRess);
      |                              ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/istream:38,
                 from /usr/include/c++/9/sstream:38,
                 from /usr/include/c++/9/complex:45,
                 from /usr/include/c++/9/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:54,
                 from bosses.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
bosses.cpp:125:30: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
  125 |         ress=min(ress, trRess);
      |                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from bosses.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
bosses.cpp:125:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  125 |         ress=min(ress, trRess);
      |                              ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from bosses.cpp:1:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
bosses.cpp:125:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
  125 |         ress=min(ress, trRess);
      |                              ^