답안 #764670

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764670 2023-06-23T20:50:52 Z adrilen Political Development (BOI17_politicaldevelopment) C++17
4 / 100
3000 ms 29372 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using ld = long double;
using arr = array<int, 2>;

constexpr int maxn = 5e4, maxk = 11;

bool visited[maxn] = { 0 };

set<int> adj[maxn];
int k;
int output = 1;


void dfs(int pos)
{
    // cout << pos << endl;
    visited[pos] = true;
    vector <bitset<maxk>> v(adj[pos].size());
    int ii = 0; // Counts which place it is in the order of adj[pos]
    int iii;
    for (int i : adj[pos])
    {
        auto it = adj[pos].begin();
        auto ft = adj[i].begin();


        iii = 0;

        v[ii][ii] = true;

        while (it != adj[pos].end() && ft != adj[i].end())
        {
            if (*it < *ft)
            {
                it++;
                iii++;
                continue;
            }

            if (*ft < *it)
            {
                ft++;
                continue;
            }

            v[ii][iii] = true;
            it++, ft++;
            iii++;
        }
        ii++;
    }

    bitset<maxk> all;

    for (int i = 1; i < (1 << (adj[pos].size())); i++){

        all.set();


        for (size_t y = 0; y < adj[pos].size(); y++) {
            if (i & (1 << y)) all &= v[y];
        }
        // cout << i << " " << all << "\n";
        if (__builtin_popcount(i) == all.count()) output = max(output, __builtin_popcount(i) + 1);
    }

    for (int i : adj[pos]) adj[i].erase(pos);

    for (int i : adj[pos]) if ((int)adj[i].size() <= k) dfs(i);
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin >> n >> k;

    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a;

        for (int y = 0; y < a; y++)
        {
            cin >> b;
            adj[i].insert(b);
        }  
    }


    for (int i = 0; i < n; i++) if (!visited[i] && (int)adj[i].size() <= k) dfs(i);

    cout << output << "\n";

    // cerr << clock() / static_cast<double>(CLOCKS_PER_SEC) << "\n";
}

/*
Det er en ganske spesiell graf og derfor kan

*/
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 3 ms 3028 KB Output is correct
4 Correct 9 ms 3072 KB Output is correct
5 Correct 12 ms 3144 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 3 ms 3028 KB Output is correct
4 Correct 9 ms 3072 KB Output is correct
5 Correct 12 ms 3144 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 7 ms 3028 KB Output is correct
12 Correct 9 ms 3028 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 28 ms 3144 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 4 ms 3028 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 4 ms 3028 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2900 KB Output is correct
21 Correct 2 ms 2900 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Execution timed out 3043 ms 3412 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Execution timed out 3066 ms 29372 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 3 ms 3028 KB Output is correct
4 Correct 9 ms 3072 KB Output is correct
5 Correct 12 ms 3144 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 7 ms 3028 KB Output is correct
12 Correct 9 ms 3028 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 28 ms 3144 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 4 ms 3028 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 4 ms 3028 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2900 KB Output is correct
21 Correct 2 ms 2900 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Execution timed out 3043 ms 3412 KB Time limit exceeded
24 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 3 ms 3028 KB Output is correct
4 Correct 9 ms 3072 KB Output is correct
5 Correct 12 ms 3144 KB Output is correct
6 Correct 4 ms 3028 KB Output is correct
7 Correct 4 ms 3028 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 7 ms 3028 KB Output is correct
12 Correct 9 ms 3028 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 28 ms 3144 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 4 ms 3028 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 4 ms 3028 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2900 KB Output is correct
21 Correct 2 ms 2900 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Execution timed out 3043 ms 3412 KB Time limit exceeded
24 Halted 0 ms 0 KB -