제출 #392805

#제출 시각아이디문제언어결과실행 시간메모리
392805victoriadBosses (BOI16_bosses)C++14
0 / 100
1 ms204 KiB
#include <cmath> #include <cstdio> #include <vector> #include <iostream> #include <algorithm> #include <utility> #include <queue> #include <map> #include <iomanip> #include <stack> #include <fstream> using namespace std; typedef long long int ll; void builddfs(vector<vector<int> >&arbol,vector<bool>&p,int nodo,vector<vector<int> >&aceptar){ queue<int>c; c.push(nodo); p[nodo]=true; while(!c.empty()){ int na=c.front(); c.pop(); p[na]=true; for(int con:aceptar[na]){ if(!p[con]){ // cout<<con<<" "<<na<<"\n"; arbol[na].push_back(con); p[con]=true; c.push(con); } } } } int salario(vector<vector<int> >&arbol,vector<int>&s,int nodo){ if(s[nodo]==1)return s[nodo]; else{ int x=1; for(int con:arbol[nodo]){ x+=salario(arbol,s,con); } s[nodo]=x; return x; } } int main(){ int n; cin>>n; vector<pair<int,int> > boss(n); for(int i=0;i<n+1;i++){ boss[i]=make_pair(0,i); } int x,l; vector<vector<int> >aceptar(n); vector<bool>p(n+1,false); for(int i=0;i<n;i++){ cin>>x; vector<int>a(x); for(int k=0;k<x;k++){ cin>>l; boss[l-1].first++; aceptar[l-1].push_back(i); } } sort(boss.rbegin(),boss.rend()); vector<vector<int> >arbol(n); builddfs(arbol,p,boss[0].second,aceptar); vector<int>s(n,0); vector<bool>(n,false); for(int i=0;i<arbol.size();i++){ if(arbol[i].size()==0){ s[i]=1; s[i]=true; } } salario(arbol,s,boss[0].second); int suma=0; for(int i=0;i<n;i++){ suma+=s[i]; } cout<<suma; return 0; }

컴파일 시 표준 에러 (stderr) 메시지

bosses.cpp: In function 'int main()':
bosses.cpp:69:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |    for(int i=0;i<arbol.size();i++){
      |                ~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...