Submission #1079474

# Submission time Handle Problem Language Result Execution time Memory
1079474 2024-08-28T15:33:59 Z andrei_iorgulescu Political Development (BOI17_politicaldevelopment) C++14
4 / 100
24 ms 25948 KB
#include <bits/stdc++.h>

using namespace std;

int n,k;
bitset<50005> bs[50005];
vector<int> g[50005];
int deg[50005];
bool luat[50005];
int cn;
vector<int> o;
bool iau[15];
int ans = 1;

void afis()
{
    for (int i = 0; i < o.size(); i++)
        for (int j = i + 1; j < o.size(); j++)
            if (iau[i] and iau[j] and !bs[o[i]][o[j]])
                return;
    ans = max(ans, 1 + (int)o.size());
}

void bkt(int pos)
{
    if (pos == o.size())
        afis();
    else
    {
        iau[pos] = false;
        bkt(pos + 1);
        iau[pos] = true;
        bkt(pos + 1);
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        int cati;
        cin >> cati;
        while (cati--)
        {
            int x;
            cin >> x;
            g[i].push_back(x);
            bs[i][x] = 1;
        }
    }
    set<pair<int,int>> cmn;
    for (int i = 0; i < n; i++)
    {
        deg[i] = g[i].size();
        cmn.insert({deg[i], i});
    }
    while (!cmn.empty())
    {
        pair<int,int> pr = *cmn.begin();
        cmn.erase(pr);
        luat[pr.second] = true;
        for (auto vec : g[pr.second])
        {
            if (!luat[vec])
            {
                vector<int> uf = g[vec];
                g[vec].clear();
                for (auto it : uf)
                    if (it != pr.second)
                        g[vec].push_back(it);
                cmn.erase({deg[vec], vec});
                deg[vec]--;
                cmn.insert({deg[vec], vec});
            }
        }
        vector<int> oameni;
        for (auto it : g[pr.second])
            if (!luat[it])
                oameni.push_back(it);
        o = oameni;
        cn = pr.second;
        bkt(0);
    }
    cout << ans;
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'void afis()':
politicaldevelopment.cpp:17:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   17 |     for (int i = 0; i < o.size(); i++)
      |                     ~~^~~~~~~~~~
politicaldevelopment.cpp:18:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |         for (int j = i + 1; j < o.size(); j++)
      |                             ~~^~~~~~~~~~
politicaldevelopment.cpp: In function 'void bkt(int)':
politicaldevelopment.cpp:26:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     if (pos == o.size())
      |         ~~~~^~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 11 ms 25692 KB Output is correct
4 Correct 23 ms 25240 KB Output is correct
5 Correct 23 ms 25176 KB Output is correct
6 Correct 13 ms 25948 KB Output is correct
7 Correct 10 ms 25436 KB Output is correct
8 Correct 2 ms 2648 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 2 ms 6752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 11 ms 25692 KB Output is correct
4 Correct 23 ms 25240 KB Output is correct
5 Correct 23 ms 25176 KB Output is correct
6 Correct 13 ms 25948 KB Output is correct
7 Correct 10 ms 25436 KB Output is correct
8 Correct 2 ms 2648 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 2 ms 6752 KB Output is correct
11 Correct 22 ms 24548 KB Output is correct
12 Correct 24 ms 23900 KB Output is correct
13 Incorrect 1 ms 2396 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB Output is correct
2 Incorrect 1 ms 2396 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 11 ms 25692 KB Output is correct
4 Correct 23 ms 25240 KB Output is correct
5 Correct 23 ms 25176 KB Output is correct
6 Correct 13 ms 25948 KB Output is correct
7 Correct 10 ms 25436 KB Output is correct
8 Correct 2 ms 2648 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 2 ms 6752 KB Output is correct
11 Correct 22 ms 24548 KB Output is correct
12 Correct 24 ms 23900 KB Output is correct
13 Incorrect 1 ms 2396 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 11 ms 25692 KB Output is correct
4 Correct 23 ms 25240 KB Output is correct
5 Correct 23 ms 25176 KB Output is correct
6 Correct 13 ms 25948 KB Output is correct
7 Correct 10 ms 25436 KB Output is correct
8 Correct 2 ms 2648 KB Output is correct
9 Correct 1 ms 2392 KB Output is correct
10 Correct 2 ms 6752 KB Output is correct
11 Correct 22 ms 24548 KB Output is correct
12 Correct 24 ms 23900 KB Output is correct
13 Incorrect 1 ms 2396 KB Output isn't correct
14 Halted 0 ms 0 KB -