Submission #735510

#TimeUsernameProblemLanguageResultExecution timeMemory
735510tigarBosses (BOI16_bosses)C++14
0 / 100
1 ms468 KiB
#include <bits/stdc++.h> using namespace std; int n; vector<int>graff[5050], tree[5050]; pair<int, int>d[5050]; bool check[5050], ch[5050]; int val[5050]; vector<int>ord; int reezz=0; void bfs(int v, int br) { if(check[v])return; check[v]=true; for(int i=0; i<graff[v].size(); i++) { if(!check[graff[v][i]]){ord.push_back(graff[v][i]); tree[v].push_back(graff[v][i]);} } if(br==ord.size())return; bfs(ord[br], br+1); } int dfs(int v) { if(ch[v])return 0; ch[v]=true; int ans=1; for(int i=0; i<tree[v].size(); i++) { ans+=dfs(tree[v][i]); } reezz+=ans; return ans; } int main() { ios_base::sync_with_stdio(false); //cin.tie(0); cout.tie(0); cin>>n; for(int i=1; i<=n; i++) { int k; cin>>k; d[i].second=i; for(int j=0; j<k; j++) { int a; cin>>a; graff[a].push_back(i); d[a].first++; } } sort(d+1, d+n+1); bfs(d[n-1].second, 0); int k=dfs(d[n-1].second); cout<<reezz; return 0; }

Compilation message (stderr)

bosses.cpp: In function 'void bfs(int, int)':
bosses.cpp:17:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for(int i=0; i<graff[v].size(); i++)
      |                  ~^~~~~~~~~~~~~~~~
bosses.cpp:21:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     if(br==ord.size())return;
      |        ~~^~~~~~~~~~~~
bosses.cpp: In function 'int dfs(int)':
bosses.cpp:31:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |     for(int i=0; i<tree[v].size(); i++)
      |                  ~^~~~~~~~~~~~~~~
bosses.cpp: In function 'int main()':
bosses.cpp:59:9: warning: unused variable 'k' [-Wunused-variable]
   59 |     int k=dfs(d[n-1].second);
      |         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...