제출 #397162

#제출 시각아이디문제언어결과실행 시간메모리
397162giorgikobBosses (BOI16_bosses)C++14
0 / 100
15 ms23808 KiB
#include<bits/stdc++.h> #define ll long long #define ff first #define ss second #define pb push_back using namespace std; const int N = 1e6+50, mod = 1e9+7, K = 31; int n,k,x; ll answer,res; vector<int>gr[N]; bool fix[N]; int cnt = 0; void dfs(int x,int h){ res += h; cnt++; fix[x] = 1; for(auto to : gr[x]){ if(fix[to]) continue; dfs(to,h+1); } } inline void test_case(){ cin >> n; for(int i = 1; i <= n; i++){ cin >> k; for(int j = 1; j <= k; j++){ cin >> x; //v[i].pb(x); gr[x].pb(i); } } ll answer = 1e18; for(int i = 1; i <= n; i++){ dfs(i,1); if(cnt == n)answer = min(answer, res); res = 0; cnt = 0; for(int j = 1; j <= n; j++) fix[j] = 0; } cout << answer << endl; } main(){ ios::sync_with_stdio(0); int T = 1; //cin >> T; for(int i = 1; i <= T; i++){ test_case(); } }

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

bosses.cpp:49:7: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   49 |  main(){
      |       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...