| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1278134 | hoangtien69 | Bosses (BOI16_bosses) | C++20 | 360 ms | 728 KiB |
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 5005;
int n;
vector<int> adj[MAXN];
int d[MAXN];
int res = INT_MAX;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
cin >> n;
for (int i = 1; i <= n; i++)
{
int k;
cin >> k;
while(k--)
{
int x;
cin >> x;
adj[x].push_back(i);
}
}
for (int i = 1; i <= n; i++)
{
memset(d, 0, sizeof d);
queue<int> q;
q.push(i);
d[i] = 1;
int cur = 0;
int dem = 0;
while(!q.empty())
{
int u = q.front();
q.pop();
cur += d[u];
dem++;
for (int v : adj[u])
{
if (d[v] == 0)
{
d[v] = d[u] + 1;
q.push(v);
}
}
}
if (dem < n)
{
continue;
}
res = min(res, cur);
}
cout << res;
}
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
| # | 결과 | 실행 시간 | 메모리 | 채점기 출력 |
|---|---|---|---|---|
| 결과를 불러오는 중입니다… | ||||
