Submission #1039138

# Submission time Handle Problem Language Result Execution time Memory
1039138 2024-07-30T13:33:49 Z n3rm1n Political Development (BOI17_politicaldevelopment) C++17
4 / 100
131 ms 34392 KB
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;
const int MAXN = 5005;
void speed()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
int n, k;
vector < int > g[MAXN];
int m;
int ok = 0, a[MAXN][MAXN];
int used[MAXN];
void dfs(int beg, int p)
{
    used[beg] = 1;
    for (auto nb: g[beg])
    {
        if(used[nb] && a[p][nb] && a[nb][beg])ok = 1;
        if(used[nb])continue;
        dfs(nb, beg);
    }
}
void read()
{
    cin >> n >> k;
    for (int i = 0; i < n; ++ i)
    {
        int cnt;
        cin >> cnt;
        m += cnt;
        while(cnt --)
        {
            int x;
            cin >> x;
            a[i][x] = 1;
            g[i].push_back(x);
        }
    }
    if(k == 1)
    {
        cout << 1 << endl;
        exit(0);
    }
    if(k == 2)
    {
        if(m)cout << 2 << endl;
        else cout << 1 << endl;
        exit(0);
    }
    if(k == 3)
    {
        int ans = 1;
        if(m)ans = 2;
        for (int i = 0; i < n; ++ i)
        {
            memset(used, 0, sizeof(used));
            dfs(i, -1);

        }
        if(ok)ans = 3;
        cout << ans << endl;
    }
}
int main()
{
    speed();

    read();
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 13 ms 34392 KB Output is correct
4 Correct 9 ms 20828 KB Output is correct
5 Correct 8 ms 20828 KB Output is correct
6 Correct 8 ms 21852 KB Output is correct
7 Correct 9 ms 22104 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 13 ms 34392 KB Output is correct
4 Correct 9 ms 20828 KB Output is correct
5 Correct 8 ms 20828 KB Output is correct
6 Correct 8 ms 21852 KB Output is correct
7 Correct 9 ms 22104 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 8 ms 20828 KB Output is correct
12 Correct 131 ms 21028 KB Output is correct
13 Incorrect 0 ms 600 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 13 ms 34392 KB Output is correct
4 Correct 9 ms 20828 KB Output is correct
5 Correct 8 ms 20828 KB Output is correct
6 Correct 8 ms 21852 KB Output is correct
7 Correct 9 ms 22104 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 8 ms 20828 KB Output is correct
12 Correct 131 ms 21028 KB Output is correct
13 Incorrect 0 ms 600 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 13 ms 34392 KB Output is correct
4 Correct 9 ms 20828 KB Output is correct
5 Correct 8 ms 20828 KB Output is correct
6 Correct 8 ms 21852 KB Output is correct
7 Correct 9 ms 22104 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 604 KB Output is correct
11 Correct 8 ms 20828 KB Output is correct
12 Correct 131 ms 21028 KB Output is correct
13 Incorrect 0 ms 600 KB Output isn't correct
14 Halted 0 ms 0 KB -