Submission #991245

# Submission time Handle Problem Language Result Execution time Memory
991245 2024-06-01T15:59:48 Z rsinventor Bosses (BOI16_bosses) C++17
0 / 100
0 ms 344 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector <ll> vll;
typedef vector<bool> vb;
typedef vector <string> vs;
typedef vector<char> vc;
typedef pair<int, int> pii;
typedef vector <pii> vpii;

#define all(a) (a).begin(), (a).end()
#define pb push_back
#define endl "\n"

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    int n;
    cin >> n;
    vector<int> adj[n];
    for(int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        for(int j = 0; j < tmp; j++) {
            int a;
            cin >> a;
            adj[--a].pb(i);
        }
    }

    ll ans = 1e10;
    for(int r = 0; r< n; r++) {
        vector<int> lvl(n);
        vector<int> visited(n);
        lvl[r] = 0;
        queue<int> q;
        q.push(r);
        while (!q.empty()) {
            int i = q.front();
            q.pop();
            visited[i] = true;
            for (int a: adj[i]) {
                if (!visited[a]) {
                    q.push(a);
                    lvl[a] = lvl[i] + 1;
                }
            }
        }
        bool flag = false;
        for(int v: visited) {
            if(!visited[v]) {
                flag = true;
                break;
            }
        }
        if(!flag) {
            continue;
        }
        ll sum = 0;
        for(int l: lvl) {
            sum += l+1;
        }
        ans = min(ans, sum);
    }

    cout << ans << endl;

    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -