Submission #1079479

#TimeUsernameProblemLanguageResultExecution timeMemory
1079479andrei_iorgulescuPolitical Development (BOI17_politicaldevelopment)C++14
100 / 100
364 ms316752 KiB
#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()
{
    int ctt = 0;
    for (int i = 0; i < o.size(); i++)
        if (iau[i])
            ctt++;
    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 + ctt);
}

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])
            {
                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 (stderr)

politicaldevelopment.cpp: In function 'void afis()':
politicaldevelopment.cpp:18:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   18 |     for (int i = 0; i < o.size(); i++)
      |                     ~~^~~~~~~~~~
politicaldevelopment.cpp:21:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |     for (int i = 0; i < o.size(); i++)
      |                     ~~^~~~~~~~~~
politicaldevelopment.cpp:22:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |         for (int j = i + 1; j < o.size(); j++)
      |                             ~~^~~~~~~~~~
politicaldevelopment.cpp: In function 'void bkt(int)':
politicaldevelopment.cpp:30:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     if (pos == o.size())
      |         ~~~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...