# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1093474 | raphaelp | Bosses (BOI16_bosses) | C++14 | 424 ms | 656 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
int main()
{
int N;
cin >> N;
vector<vector<int>> AR(N);
for (int i = 0; i < N; i++)
{
int k;
cin >> k;
for (int j = 0; j < k; j++)
{
int x;
cin >> x;
x--;
AR[x].push_back(i);
}
}
int best = 1000000000;
for (int root = 0; root < N; root++)
{
vector<int> occ(N);
occ[root] = 1;
int score = 0, nb = 0;
queue<int> Q;
Q.push(root);
while (!Q.empty())
{
int x = Q.front();
nb++;
Q.pop();
score += occ[x];
for (int i = 0; i < AR[x].size(); i++)
{
if (occ[AR[x][i]] == 0)
{
occ[AR[x][i]] = occ[x] + 1;
Q.push(AR[x][i]);
}
}
}
if (nb == N)
best = min(best, score);
}
cout << best;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |