제출 #771317

#제출 시각아이디문제언어결과실행 시간메모리
771317peraBosses (BOI16_bosses)C++17
0 / 100
5 ms8168 KiB
#include<bits/stdc++.h> using namespace std; #define int long long const int N = 2e5 + 1; int n , ans , c; vector<int> g[N] , v(N) , d(N); void dfs(int u){ v[u] = 1; c += d[u]; for(int i = 0;i < g[u].size();i ++){ if(!v[g[u][i]]){ d[g[u][i]] = d[u] + 1; dfs(g[u][i]); } } } main(){ ios::sync_with_stdio(0); cin.tie(0),cout.tie(0); cin >> n; for(int i = 1;i <= n;i ++){ int k;cin >> k; for(int j = 1;j <= k;j ++){ int v;cin >> v; g[v].push_back(i); } } ans = INT_MAX; for(int boss = 1;boss <= n;boss ++){ for(int i = 1;i <= n;i ++){ d[i] = v[i] = 0; } c = 0; d[boss] = 1; dfs(boss); if(accumulate(v.begin() , v.end() , 0) == n) ans = min(ans , c); } cout << ans << endl; }

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

bosses.cpp: In function 'void dfs(long long int)':
bosses.cpp:14:18: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |  for(int i = 0;i < g[u].size();i ++){
      |                ~~^~~~~~~~~~~~~
bosses.cpp: At global scope:
bosses.cpp:22:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   22 | main(){
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...