Submission #936258

#TimeUsernameProblemLanguageResultExecution timeMemory
936258wateronennBosses (BOI16_bosses)C++14
0 / 100
1 ms2652 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e5+9; vector<int> g[N]; bool visit[N]={0}; int dfs(int u){ visit[u] = true; int nub = 1; for(auto v : g[u]){ if(!visit[v]){ nub+=dfs(v); } } return nub; } int main(){ cin.tie(0)->sync_with_stdio(false); int n,m; cin>>n; for(int i=1;i<=n;i++){ int k; cin>>k; for(int j=1;j<=k;j++){ cin>>m; g[i].push_back(m); } } int sum = 0; for(int i=1;i<=n;i++){ if(!visit[i]) { int res = dfs(i); // cout<<res<<" "; sum += 1<<res-1; } } cout<<sum; return 0; } /* 4 1 4 3 1 3 4 2 1 2 1 3 */

Compilation message (stderr)

bosses.cpp: In function 'int main()':
bosses.cpp:36:17: warning: suggest parentheses around '-' inside '<<' [-Wparentheses]
   36 |    sum += 1<<res-1;
      |              ~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...