Submission #1103339

# Submission time Handle Problem Language Result Execution time Memory
1103339 2024-10-20T17:02:36 Z alexdd Political Development (BOI17_politicaldevelopment) C++17
100 / 100
296 ms 28752 KB
#include <bits/stdc++.h>
using namespace std;
int n,k,mxm;
set<int> con[50005];
set<pair<int,int>> s;
int b[20];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);
    cin>>n>>k;
    mxm=1;
    for(int i=1;i<=n;i++)
    {
        int nr,x;
        cin>>nr;
        for(int j=0;j<nr;j++)
        {
            cin>>x;
            x++;
            con[i].insert(x);
        }
        s.insert({nr,i});
    }
    for(int pas=1;pas<=n;pas++)
    {
        auto it = s.begin();
        int nod = (*it).second;
        s.erase(it);

        vector<int> v;
        for(auto j:con[nod])
            v.push_back(j);
        assert((int)v.size() < k);

        for(int config=1;config<(1<<((int)v.size()));config++)
        {
            int cnt=0;
            for(int j=0;j<v.size();j++)
            {
                if((1<<j)&config)
                {
                    b[cnt++]=v[j];
                }
            }
            if(cnt+1>mxm)
            {
                bool bun=1;
                for(int i=0;i<cnt;i++)
                {
                    for(int j=i+1;j<cnt;j++)
                    {
                        if(con[b[i]].find(b[j])==con[b[i]].end())
                        {
                            bun=0;
                            break;
                        }
                    }
                    if(!bun)
                        break;
                }
                if(bun)
                {
                    mxm = cnt+1;
                    if(mxm==k)
                    {
                        cout<<k;
                        return 0;
                    }
                }
            }
        }

        for(auto j:con[nod])
        {
            s.erase({con[j].size(),j});
            con[j].erase(nod);
            s.insert({con[j].size(),j});
        }
    }
    cout<<mxm;
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:38:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             for(int j=0;j<v.size();j++)
      |                         ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 3 ms 3408 KB Output is correct
4 Correct 3 ms 3408 KB Output is correct
5 Correct 4 ms 3408 KB Output is correct
6 Correct 4 ms 3408 KB Output is correct
7 Correct 3 ms 3408 KB Output is correct
8 Correct 2 ms 2896 KB Output is correct
9 Correct 2 ms 2640 KB Output is correct
10 Correct 2 ms 2896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 3 ms 3408 KB Output is correct
4 Correct 3 ms 3408 KB Output is correct
5 Correct 4 ms 3408 KB Output is correct
6 Correct 4 ms 3408 KB Output is correct
7 Correct 3 ms 3408 KB Output is correct
8 Correct 2 ms 2896 KB Output is correct
9 Correct 2 ms 2640 KB Output is correct
10 Correct 2 ms 2896 KB Output is correct
11 Correct 4 ms 3408 KB Output is correct
12 Correct 5 ms 3408 KB Output is correct
13 Correct 1 ms 2640 KB Output is correct
14 Correct 4 ms 3516 KB Output is correct
15 Correct 1 ms 2640 KB Output is correct
16 Correct 5 ms 3412 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 4 ms 3412 KB Output is correct
19 Correct 2 ms 2900 KB Output is correct
20 Correct 3 ms 3324 KB Output is correct
21 Correct 3 ms 3156 KB Output is correct
22 Correct 2 ms 2900 KB Output is correct
23 Correct 4 ms 3592 KB Output is correct
24 Correct 2 ms 2900 KB Output is correct
25 Correct 4 ms 3668 KB Output is correct
26 Correct 5 ms 3412 KB Output is correct
27 Correct 4 ms 3412 KB Output is correct
28 Correct 5 ms 3576 KB Output is correct
29 Correct 4 ms 3412 KB Output is correct
30 Correct 5 ms 3668 KB Output is correct
31 Correct 5 ms 3668 KB Output is correct
32 Correct 5 ms 3524 KB Output is correct
33 Correct 6 ms 3668 KB Output is correct
34 Correct 5 ms 3668 KB Output is correct
35 Correct 3 ms 3156 KB Output is correct
36 Correct 3 ms 3156 KB Output is correct
37 Correct 3 ms 3320 KB Output is correct
38 Correct 2 ms 2900 KB Output is correct
39 Correct 3 ms 3044 KB Output is correct
40 Correct 4 ms 3924 KB Output is correct
41 Correct 3 ms 2900 KB Output is correct
42 Correct 4 ms 3924 KB Output is correct
43 Correct 6 ms 3924 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2896 KB Output is correct
2 Correct 1 ms 2808 KB Output is correct
3 Correct 1 ms 2640 KB Output is correct
4 Correct 1 ms 2640 KB Output is correct
5 Correct 1 ms 2816 KB Output is correct
6 Correct 1 ms 2644 KB Output is correct
7 Correct 1 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 Correct 265 ms 28724 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 257 ms 28748 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 279 ms 28752 KB Output is correct
16 Correct 270 ms 28740 KB Output is correct
17 Correct 285 ms 28748 KB Output is correct
18 Correct 296 ms 28748 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 3 ms 3408 KB Output is correct
4 Correct 3 ms 3408 KB Output is correct
5 Correct 4 ms 3408 KB Output is correct
6 Correct 4 ms 3408 KB Output is correct
7 Correct 3 ms 3408 KB Output is correct
8 Correct 2 ms 2896 KB Output is correct
9 Correct 2 ms 2640 KB Output is correct
10 Correct 2 ms 2896 KB Output is correct
11 Correct 4 ms 3408 KB Output is correct
12 Correct 5 ms 3408 KB Output is correct
13 Correct 1 ms 2640 KB Output is correct
14 Correct 4 ms 3516 KB Output is correct
15 Correct 1 ms 2640 KB Output is correct
16 Correct 5 ms 3412 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 4 ms 3412 KB Output is correct
19 Correct 2 ms 2900 KB Output is correct
20 Correct 3 ms 3324 KB Output is correct
21 Correct 3 ms 3156 KB Output is correct
22 Correct 2 ms 2900 KB Output is correct
23 Correct 4 ms 3592 KB Output is correct
24 Correct 2 ms 2900 KB Output is correct
25 Correct 4 ms 3668 KB Output is correct
26 Correct 5 ms 3412 KB Output is correct
27 Correct 4 ms 3412 KB Output is correct
28 Correct 5 ms 3576 KB Output is correct
29 Correct 4 ms 3412 KB Output is correct
30 Correct 5 ms 3668 KB Output is correct
31 Correct 5 ms 3668 KB Output is correct
32 Correct 5 ms 3524 KB Output is correct
33 Correct 6 ms 3668 KB Output is correct
34 Correct 5 ms 3668 KB Output is correct
35 Correct 3 ms 3156 KB Output is correct
36 Correct 3 ms 3156 KB Output is correct
37 Correct 3 ms 3320 KB Output is correct
38 Correct 2 ms 2900 KB Output is correct
39 Correct 3 ms 3044 KB Output is correct
40 Correct 4 ms 3924 KB Output is correct
41 Correct 3 ms 2900 KB Output is correct
42 Correct 4 ms 3924 KB Output is correct
43 Correct 6 ms 3924 KB Output is correct
44 Correct 15 ms 4948 KB Output is correct
45 Correct 2 ms 2812 KB Output is correct
46 Correct 9 ms 3864 KB Output is correct
47 Correct 17 ms 5060 KB Output is correct
48 Correct 9 ms 4088 KB Output is correct
49 Correct 16 ms 4948 KB Output is correct
50 Correct 17 ms 4948 KB Output is correct
51 Correct 85 ms 6996 KB Output is correct
52 Correct 3 ms 3576 KB Output is correct
53 Correct 79 ms 7620 KB Output is correct
54 Correct 150 ms 7508 KB Output is correct
55 Correct 5 ms 3412 KB Output is correct
56 Correct 4 ms 3544 KB Output is correct
57 Correct 2 ms 2900 KB Output is correct
58 Correct 76 ms 7676 KB Output is correct
59 Correct 6 ms 3924 KB Output is correct
60 Correct 5 ms 3412 KB Output is correct
61 Correct 7 ms 3924 KB Output is correct
62 Correct 7 ms 3924 KB Output is correct
63 Correct 14 ms 4948 KB Output is correct
64 Correct 11 ms 4692 KB Output is correct
65 Correct 8 ms 3932 KB Output is correct
66 Correct 6 ms 3924 KB Output is correct
67 Correct 24 ms 5460 KB Output is correct
68 Correct 11 ms 4692 KB Output is correct
69 Correct 7 ms 3924 KB Output is correct
70 Correct 14 ms 4888 KB Output is correct
71 Correct 23 ms 5508 KB Output is correct
72 Correct 21 ms 5424 KB Output is correct
73 Correct 4 ms 3412 KB Output is correct
74 Correct 15 ms 4944 KB Output is correct
75 Correct 20 ms 5464 KB Output is correct
76 Correct 11 ms 4436 KB Output is correct
77 Correct 44 ms 6012 KB Output is correct
78 Correct 5 ms 3412 KB Output is correct
79 Correct 19 ms 4344 KB Output is correct
80 Correct 10 ms 4180 KB Output is correct
81 Correct 41 ms 6016 KB Output is correct
82 Correct 3 ms 2900 KB Output is correct
83 Correct 21 ms 4416 KB Output is correct
84 Correct 21 ms 5376 KB Output is correct
85 Correct 3 ms 2900 KB Output is correct
86 Correct 19 ms 5204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2640 KB Output is correct
2 Correct 1 ms 2640 KB Output is correct
3 Correct 3 ms 3408 KB Output is correct
4 Correct 3 ms 3408 KB Output is correct
5 Correct 4 ms 3408 KB Output is correct
6 Correct 4 ms 3408 KB Output is correct
7 Correct 3 ms 3408 KB Output is correct
8 Correct 2 ms 2896 KB Output is correct
9 Correct 2 ms 2640 KB Output is correct
10 Correct 2 ms 2896 KB Output is correct
11 Correct 4 ms 3408 KB Output is correct
12 Correct 5 ms 3408 KB Output is correct
13 Correct 1 ms 2640 KB Output is correct
14 Correct 4 ms 3516 KB Output is correct
15 Correct 1 ms 2640 KB Output is correct
16 Correct 5 ms 3412 KB Output is correct
17 Correct 1 ms 2644 KB Output is correct
18 Correct 4 ms 3412 KB Output is correct
19 Correct 2 ms 2900 KB Output is correct
20 Correct 3 ms 3324 KB Output is correct
21 Correct 3 ms 3156 KB Output is correct
22 Correct 2 ms 2900 KB Output is correct
23 Correct 4 ms 3592 KB Output is correct
24 Correct 2 ms 2900 KB Output is correct
25 Correct 4 ms 3668 KB Output is correct
26 Correct 5 ms 3412 KB Output is correct
27 Correct 4 ms 3412 KB Output is correct
28 Correct 5 ms 3576 KB Output is correct
29 Correct 4 ms 3412 KB Output is correct
30 Correct 5 ms 3668 KB Output is correct
31 Correct 5 ms 3668 KB Output is correct
32 Correct 5 ms 3524 KB Output is correct
33 Correct 6 ms 3668 KB Output is correct
34 Correct 5 ms 3668 KB Output is correct
35 Correct 3 ms 3156 KB Output is correct
36 Correct 3 ms 3156 KB Output is correct
37 Correct 3 ms 3320 KB Output is correct
38 Correct 2 ms 2900 KB Output is correct
39 Correct 3 ms 3044 KB Output is correct
40 Correct 4 ms 3924 KB Output is correct
41 Correct 3 ms 2900 KB Output is correct
42 Correct 4 ms 3924 KB Output is correct
43 Correct 6 ms 3924 KB Output is correct
44 Correct 1 ms 2644 KB Output is correct
45 Correct 164 ms 20828 KB Output is correct
46 Correct 64 ms 13072 KB Output is correct
47 Correct 173 ms 20812 KB Output is correct
48 Correct 139 ms 20816 KB Output is correct
49 Correct 28 ms 10480 KB Output is correct
50 Correct 142 ms 26188 KB Output is correct
51 Correct 139 ms 20804 KB Output is correct
52 Correct 38 ms 10336 KB Output is correct
53 Correct 30 ms 10316 KB Output is correct
54 Correct 10 ms 5204 KB Output is correct
55 Correct 153 ms 26248 KB Output is correct
56 Correct 23 ms 7664 KB Output is correct
57 Correct 39 ms 10480 KB Output is correct
58 Correct 46 ms 13140 KB Output is correct
59 Correct 23 ms 7764 KB Output is correct
60 Correct 23 ms 7764 KB Output is correct
61 Correct 50 ms 13220 KB Output is correct
62 Correct 34 ms 10324 KB Output is correct
63 Correct 77 ms 14420 KB Output is correct
64 Correct 23 ms 7764 KB Output is correct
65 Correct 105 ms 16980 KB Output is correct
66 Correct 34 ms 10324 KB Output is correct
67 Correct 78 ms 14412 KB Output is correct
68 Correct 109 ms 16204 KB Output is correct
69 Correct 106 ms 16972 KB Output is correct
70 Correct 36 ms 10316 KB Output is correct
71 Correct 97 ms 16380 KB Output is correct
72 Correct 70 ms 13900 KB Output is correct
73 Correct 115 ms 18772 KB Output is correct
74 Correct 43 ms 10336 KB Output is correct
75 Correct 43 ms 8980 KB Output is correct
76 Correct 77 ms 13908 KB Output is correct
77 Correct 132 ms 18764 KB Output is correct
78 Correct 58 ms 10580 KB Output is correct
79 Correct 41 ms 9044 KB Output is correct
80 Correct 20 ms 5972 KB Output is correct
81 Correct 54 ms 10592 KB Output is correct
82 Correct 98 ms 15700 KB Output is correct
83 Correct 21 ms 5972 KB Output is correct
84 Correct 95 ms 15700 KB Output is correct