제출 #400913

#제출 시각아이디문제언어결과실행 시간메모리
400913Pichon5Bosses (BOI16_bosses)C++17
67 / 100
1577 ms1004 KiB
#include <bits/stdc++.h> #define pb push_back #define vi vector<int> #define F first #define ll long long #define S second #define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; vector<vi>G,G2; ll suma[5001]; ll sum=0; vector<bool>vis; void dfs(int nodo, int p){ suma[nodo]=1; for(int i=0;i<G2[nodo].size();i++){ int to=G2[nodo][i]; if(to==p)continue; dfs(to,nodo); suma[nodo]+=suma[to]; } sum+=suma[nodo]; } int main() { fast int n,x,k; cin>>n; G.resize(n+1); for(int i=1;i<=n;i++){ cin>>k; for(int l=0;l<k;l++){ cin>>x; G[x].pb(i); } } ll res=1e16; for(int i=1;i<=n;i++){ G2.assign(n+1,vi()); vis.assign(n+1,false); queue<int>q; int cant=0; q.push(i); vis[i]=1; while(!q.empty()){ int nodo=q.front(); q.pop(); cant++; for(int l=0;l<G[nodo].size();l++){ int to=G[nodo][l]; if(!vis[to]){ G2[nodo].pb(to); G2[to].pb(nodo); vis[to]=1; q.push(to); } } } if(cant!=n){ continue; } sum=0; dfs(i,-1); res=min(res,sum); } cout<<res<<"\n"; return 0; }

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

bosses.cpp: In function 'void dfs(int, int)':
bosses.cpp:16:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |     for(int i=0;i<G2[nodo].size();i++){
      |                 ~^~~~~~~~~~~~~~~~
bosses.cpp: In function 'int main()':
bosses.cpp:49:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |             for(int l=0;l<G[nodo].size();l++){
      |                         ~^~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...