제출 #233988

#제출 시각아이디문제언어결과실행 시간메모리
233988DS007Bosses (BOI16_bosses)C++14
0 / 100
5 ms512 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int N = 5000; vector<int> adj[N]; bool used[N]; int sal[N]; int n, c; int calc(int v) { vector<int> q; for (int i : adj[v]) { if (!used[i]) q.push_back(i), used[i] = true, c++; } int sum = 1; for (int i : q) sum += calc(i); return sal[v] = sum; } int solveTestCase(int test) { cin >> n; for (int i = 0; i < n; i++) { int k, v; cin >> k; while (k--) { cin >> v; adj[v - 1].push_back(i); } } int ans = 1e18; for (int i = 0; i < n; i++) { fill(used, used + N, false); c = 1; used[i] = true; calc(i); int val = 0; for (int j = 0; j < n; j++) val += sal[j]; if (c == n) ans = min(ans, val); } cout << ans; } signed main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); int test = 1; //cin >> test; for (int i = 1; i <= test; i++) solveTestCase(i); }

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

bosses.cpp: In function 'long long int solveTestCase(long long int)':
bosses.cpp:51:1: warning: no return statement in function returning non-void [-Wreturn-type]
 }
 ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...