# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
938905 |
2024-03-05T19:26:32 Z |
vjudge1 |
Bosses (BOI16_bosses) |
C++17 |
|
0 ms |
348 KB |
#include<bits/stdc++.h>
using namespace std;
const int INF = 1e9;
const int MAXN = 5e3;
int N;
vector<int> children[MAXN + 5];
bool vis[MAXN + 5];
int dfs(int cur, int depth) {
vis[cur] = true;
int ans = depth;
for (auto child: children[cur]) {
if (vis[child]) continue;
ans += dfs(child, depth + 1);
}
return ans;
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
cin >> N;
for (int i = 0; i < N; i++) {
int sz; cin >> sz;
while (sz--) {
int u; cin >> u; u--;
children[i].push_back(u);
}
}
int ans = INF;
for (int i = 0; i < N; i++) {
memset(vis, false, sizeof vis);
ans = min(ans, dfs(i, 1));
}
cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |