답안 #445708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
445708 2021-07-19T10:41:09 Z prvocislo Political Development (BOI17_politicaldevelopment) C++17
4 / 100
7 ms 1228 KB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<set<int> > g(n);
    set<pair<int, int> > pq;
    for (int u = 0, d; u < n; u++)
    {
        cin >> d;
        for (int j = 0, v; j < d; j++) cin >> v, g[u].insert(v);
        pq.insert({d, u});
    }
    int ans = 1;
    while (!pq.empty())
    {
        int u = pq.begin()->second;
        pq.erase(pq.begin());
        vector<int> c = {u};
        for (int v : g[u]) c.push_back(v);
        vector<int> g2(c.size(), 0);
        for (int i = 0; i < c.size(); i++) for (int j = 0; j < c.size(); j++)
            if (g[i].count(j)) g2[i] |= (1 << j);
        for (int i = 1; i < (1 << c.size()); i += 2) // prvy bit musime mat
        {
            int cnt = __builtin_popcount(i);
            if (cnt <= ans) continue;
            bool ok = true;
            for (int u = 1; u < c.size(); u++)
            {
                if (!(i & (1<<u))) continue;
                for (int v = u+1; v < c.size(); v++)
                {
                    if (!(i & (1<<v))) continue;
                    if (!(g2[u] & (1<<v)))
                    {
                        ok = false;
                        break;
                    } 
                } 
                if (!ok) break;
            }
            if (ok) ans = max(ans, cnt);
        }
        for (int v : g[u])
        {
            pq.erase({g[v].size(), v});
            g[v].erase(u);
            pq.insert({g[v].size(), v});
        }
    }
    cout << ans << "\n";
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:26:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for (int i = 0; i < c.size(); i++) for (int j = 0; j < c.size(); j++)
      |                         ~~^~~~~~~~~~
politicaldevelopment.cpp:26:62: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |         for (int i = 0; i < c.size(); i++) for (int j = 0; j < c.size(); j++)
      |                                                            ~~^~~~~~~~~~
politicaldevelopment.cpp:33:31: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |             for (int u = 1; u < c.size(); u++)
      |                             ~~^~~~~~~~~~
politicaldevelopment.cpp:36:37: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |                 for (int v = u+1; v < c.size(); v++)
      |                                   ~~^~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 7 ms 1228 KB Output is correct
4 Correct 6 ms 1228 KB Output is correct
5 Correct 6 ms 1228 KB Output is correct
6 Correct 7 ms 1228 KB Output is correct
7 Correct 6 ms 1228 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 7 ms 1228 KB Output is correct
4 Correct 6 ms 1228 KB Output is correct
5 Correct 6 ms 1228 KB Output is correct
6 Correct 7 ms 1228 KB Output is correct
7 Correct 6 ms 1228 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 6 ms 1228 KB Output is correct
12 Correct 7 ms 1228 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 6 ms 1216 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 6 ms 1228 KB Output is correct
17 Incorrect 0 ms 204 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 716 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 7 ms 1228 KB Output is correct
4 Correct 6 ms 1228 KB Output is correct
5 Correct 6 ms 1228 KB Output is correct
6 Correct 7 ms 1228 KB Output is correct
7 Correct 6 ms 1228 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 6 ms 1228 KB Output is correct
12 Correct 7 ms 1228 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 6 ms 1216 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 6 ms 1228 KB Output is correct
17 Incorrect 0 ms 204 KB Output isn't correct
18 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 7 ms 1228 KB Output is correct
4 Correct 6 ms 1228 KB Output is correct
5 Correct 6 ms 1228 KB Output is correct
6 Correct 7 ms 1228 KB Output is correct
7 Correct 6 ms 1228 KB Output is correct
8 Correct 2 ms 716 KB Output is correct
9 Correct 0 ms 204 KB Output is correct
10 Correct 2 ms 716 KB Output is correct
11 Correct 6 ms 1228 KB Output is correct
12 Correct 7 ms 1228 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 6 ms 1216 KB Output is correct
15 Correct 0 ms 204 KB Output is correct
16 Correct 6 ms 1228 KB Output is correct
17 Incorrect 0 ms 204 KB Output isn't correct
18 Halted 0 ms 0 KB -