Submission #218626

# Submission time Handle Problem Language Result Execution time Memory
218626 2020-04-02T12:02:29 Z MKopchev Political Development (BOI17_politicaldevelopment) C++14
100 / 100
545 ms 28932 KB
#include<bits/stdc++.h>
using namespace std;
const int nmax=5e4+42,kmax=20;
int n,k;

set<int> adj[nmax];

priority_queue< pair<int/*size*/,int/*node*/> > pq;

int output;

int active[kmax],pointer=0;

int bitmasks[nmax];

void solve(int node)
{
    active[0]=node;
    pointer=1;

    for(auto k:adj[node])
    {
        active[pointer]=k;
        pointer++;
    }

    for(int i=0;i<pointer;i++)
        bitmasks[i]=0;

    for(int i=0;i<pointer;i++)
        for(int j=0;j<pointer;j++)
        {
            if(i==j||adj[active[i]].count(active[j]))
                bitmasks[i]+=(1<<j);
        }
    /*
    cout<<"active: ";for(int i=0;i<pointer;i++)cout<<active[i]<<" ";cout<<endl;
    cout<<"masks: ";for(int i=0;i<pointer;i++)cout<<bitmasks[i]<<" ";cout<<endl;
    */

    for(int to_test=0;to_test<(1<<pointer);to_test++)
    {
        int in=0;
        for(int j=0;j<pointer;j++)
            if((to_test&(1<<j)))
            {
                if((bitmasks[j]&to_test)!=to_test)in=-1e9;
                else in++;
            }
        output=max(output,in);
    }
}
int main()
{
    scanf("%i%i",&n,&k);
    for(int i=0;i<n;i++)
    {
        int sz,node;
        scanf("%i",&sz);
        for(int j=1;j<=sz;j++)
        {
            scanf("%i",&node);
            adj[i].insert(node);
            adj[node].insert(i);
        }
    }

    for(int i=0;i<n;i++)
        pq.push({-adj[i].size(),i});

    for(int turn=0;turn<n;turn++)
    {
        while(adj[pq.top().second].size()!=-pq.top().first)pq.pop();//incorrect size

        int current=pq.top().second;
        pq.pop();

        //cout<<"current= "<<current<<endl;

        solve(current);

        for(auto k:adj[current])
        {
            adj[k].erase(current);
            pq.push({-adj[k].size(),k});
        }
        adj[current]={};
    }

    printf("%i\n",output);
    return 0;
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:73:42: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
         while(adj[pq.top().second].size()!=-pq.top().first)pq.pop();//incorrect size
               ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
politicaldevelopment.cpp:55:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%i%i",&n,&k);
     ~~~~~^~~~~~~~~~~~~~
politicaldevelopment.cpp:59:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%i",&sz);
         ~~~~~^~~~~~~~~~
politicaldevelopment.cpp:62:18: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
             scanf("%i",&node);
             ~~~~~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 11 ms 3328 KB Output is correct
4 Correct 11 ms 3328 KB Output is correct
5 Correct 14 ms 3328 KB Output is correct
6 Correct 11 ms 3328 KB Output is correct
7 Correct 11 ms 3328 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 11 ms 3328 KB Output is correct
4 Correct 11 ms 3328 KB Output is correct
5 Correct 14 ms 3328 KB Output is correct
6 Correct 11 ms 3328 KB Output is correct
7 Correct 11 ms 3328 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
11 Correct 11 ms 3328 KB Output is correct
12 Correct 11 ms 3328 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 11 ms 3328 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 11 ms 3328 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 11 ms 3328 KB Output is correct
19 Correct 7 ms 2816 KB Output is correct
20 Correct 8 ms 3072 KB Output is correct
21 Correct 8 ms 3072 KB Output is correct
22 Correct 7 ms 2816 KB Output is correct
23 Correct 12 ms 3456 KB Output is correct
24 Correct 7 ms 2816 KB Output is correct
25 Correct 12 ms 3584 KB Output is correct
26 Correct 12 ms 3456 KB Output is correct
27 Correct 10 ms 3328 KB Output is correct
28 Correct 12 ms 3328 KB Output is correct
29 Correct 11 ms 3328 KB Output is correct
30 Correct 13 ms 3456 KB Output is correct
31 Correct 12 ms 3456 KB Output is correct
32 Correct 13 ms 3456 KB Output is correct
33 Correct 13 ms 3456 KB Output is correct
34 Correct 12 ms 3456 KB Output is correct
35 Correct 9 ms 3072 KB Output is correct
36 Correct 9 ms 3072 KB Output is correct
37 Correct 9 ms 3072 KB Output is correct
38 Correct 8 ms 2944 KB Output is correct
39 Correct 8 ms 2944 KB Output is correct
40 Correct 16 ms 3968 KB Output is correct
41 Correct 8 ms 2944 KB Output is correct
42 Correct 16 ms 3968 KB Output is correct
43 Correct 16 ms 3968 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 7 ms 2816 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 6 ms 2688 KB Output is correct
4 Correct 6 ms 2688 KB Output is correct
5 Correct 6 ms 2688 KB Output is correct
6 Correct 6 ms 2688 KB Output is correct
7 Correct 6 ms 2688 KB Output is correct
8 Correct 6 ms 2688 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 6 ms 2688 KB Output is correct
11 Correct 495 ms 28652 KB Output is correct
12 Correct 6 ms 2688 KB Output is correct
13 Correct 528 ms 28932 KB Output is correct
14 Correct 6 ms 2688 KB Output is correct
15 Correct 524 ms 28652 KB Output is correct
16 Correct 538 ms 28652 KB Output is correct
17 Correct 545 ms 28772 KB Output is correct
18 Correct 522 ms 28912 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 11 ms 3328 KB Output is correct
4 Correct 11 ms 3328 KB Output is correct
5 Correct 14 ms 3328 KB Output is correct
6 Correct 11 ms 3328 KB Output is correct
7 Correct 11 ms 3328 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
11 Correct 11 ms 3328 KB Output is correct
12 Correct 11 ms 3328 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 11 ms 3328 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 11 ms 3328 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 11 ms 3328 KB Output is correct
19 Correct 7 ms 2816 KB Output is correct
20 Correct 8 ms 3072 KB Output is correct
21 Correct 8 ms 3072 KB Output is correct
22 Correct 7 ms 2816 KB Output is correct
23 Correct 12 ms 3456 KB Output is correct
24 Correct 7 ms 2816 KB Output is correct
25 Correct 12 ms 3584 KB Output is correct
26 Correct 12 ms 3456 KB Output is correct
27 Correct 10 ms 3328 KB Output is correct
28 Correct 12 ms 3328 KB Output is correct
29 Correct 11 ms 3328 KB Output is correct
30 Correct 13 ms 3456 KB Output is correct
31 Correct 12 ms 3456 KB Output is correct
32 Correct 13 ms 3456 KB Output is correct
33 Correct 13 ms 3456 KB Output is correct
34 Correct 12 ms 3456 KB Output is correct
35 Correct 9 ms 3072 KB Output is correct
36 Correct 9 ms 3072 KB Output is correct
37 Correct 9 ms 3072 KB Output is correct
38 Correct 8 ms 2944 KB Output is correct
39 Correct 8 ms 2944 KB Output is correct
40 Correct 16 ms 3968 KB Output is correct
41 Correct 8 ms 2944 KB Output is correct
42 Correct 16 ms 3968 KB Output is correct
43 Correct 16 ms 3968 KB Output is correct
44 Correct 40 ms 4864 KB Output is correct
45 Correct 6 ms 2688 KB Output is correct
46 Correct 17 ms 3968 KB Output is correct
47 Correct 29 ms 5112 KB Output is correct
48 Correct 16 ms 3892 KB Output is correct
49 Correct 30 ms 5112 KB Output is correct
50 Correct 30 ms 5112 KB Output is correct
51 Correct 121 ms 7412 KB Output is correct
52 Correct 11 ms 3328 KB Output is correct
53 Correct 231 ms 7544 KB Output is correct
54 Correct 237 ms 7928 KB Output is correct
55 Correct 11 ms 3328 KB Output is correct
56 Correct 11 ms 3328 KB Output is correct
57 Correct 7 ms 2816 KB Output is correct
58 Correct 238 ms 7544 KB Output is correct
59 Correct 16 ms 3840 KB Output is correct
60 Correct 11 ms 3328 KB Output is correct
61 Correct 15 ms 3840 KB Output is correct
62 Correct 15 ms 3840 KB Output is correct
63 Correct 39 ms 4864 KB Output is correct
64 Correct 29 ms 4608 KB Output is correct
65 Correct 14 ms 3772 KB Output is correct
66 Correct 15 ms 3840 KB Output is correct
67 Correct 44 ms 5496 KB Output is correct
68 Correct 28 ms 4608 KB Output is correct
69 Correct 15 ms 3712 KB Output is correct
70 Correct 27 ms 4736 KB Output is correct
71 Correct 42 ms 5376 KB Output is correct
72 Correct 38 ms 5496 KB Output is correct
73 Correct 10 ms 3328 KB Output is correct
74 Correct 30 ms 4864 KB Output is correct
75 Correct 48 ms 5496 KB Output is correct
76 Correct 21 ms 4224 KB Output is correct
77 Correct 58 ms 6008 KB Output is correct
78 Correct 10 ms 3328 KB Output is correct
79 Correct 32 ms 4352 KB Output is correct
80 Correct 21 ms 4352 KB Output is correct
81 Correct 61 ms 6136 KB Output is correct
82 Correct 8 ms 2944 KB Output is correct
83 Correct 32 ms 4344 KB Output is correct
84 Correct 36 ms 5368 KB Output is correct
85 Correct 8 ms 2944 KB Output is correct
86 Correct 36 ms 5376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 2688 KB Output is correct
2 Correct 6 ms 2688 KB Output is correct
3 Correct 11 ms 3328 KB Output is correct
4 Correct 11 ms 3328 KB Output is correct
5 Correct 14 ms 3328 KB Output is correct
6 Correct 11 ms 3328 KB Output is correct
7 Correct 11 ms 3328 KB Output is correct
8 Correct 7 ms 2816 KB Output is correct
9 Correct 6 ms 2688 KB Output is correct
10 Correct 7 ms 2816 KB Output is correct
11 Correct 11 ms 3328 KB Output is correct
12 Correct 11 ms 3328 KB Output is correct
13 Correct 6 ms 2688 KB Output is correct
14 Correct 11 ms 3328 KB Output is correct
15 Correct 6 ms 2688 KB Output is correct
16 Correct 11 ms 3328 KB Output is correct
17 Correct 6 ms 2688 KB Output is correct
18 Correct 11 ms 3328 KB Output is correct
19 Correct 7 ms 2816 KB Output is correct
20 Correct 8 ms 3072 KB Output is correct
21 Correct 8 ms 3072 KB Output is correct
22 Correct 7 ms 2816 KB Output is correct
23 Correct 12 ms 3456 KB Output is correct
24 Correct 7 ms 2816 KB Output is correct
25 Correct 12 ms 3584 KB Output is correct
26 Correct 12 ms 3456 KB Output is correct
27 Correct 10 ms 3328 KB Output is correct
28 Correct 12 ms 3328 KB Output is correct
29 Correct 11 ms 3328 KB Output is correct
30 Correct 13 ms 3456 KB Output is correct
31 Correct 12 ms 3456 KB Output is correct
32 Correct 13 ms 3456 KB Output is correct
33 Correct 13 ms 3456 KB Output is correct
34 Correct 12 ms 3456 KB Output is correct
35 Correct 9 ms 3072 KB Output is correct
36 Correct 9 ms 3072 KB Output is correct
37 Correct 9 ms 3072 KB Output is correct
38 Correct 8 ms 2944 KB Output is correct
39 Correct 8 ms 2944 KB Output is correct
40 Correct 16 ms 3968 KB Output is correct
41 Correct 8 ms 2944 KB Output is correct
42 Correct 16 ms 3968 KB Output is correct
43 Correct 16 ms 3968 KB Output is correct
44 Correct 6 ms 2688 KB Output is correct
45 Correct 273 ms 20972 KB Output is correct
46 Correct 116 ms 11252 KB Output is correct
47 Correct 273 ms 20716 KB Output is correct
48 Correct 264 ms 20880 KB Output is correct
49 Correct 75 ms 8696 KB Output is correct
50 Correct 343 ms 24944 KB Output is correct
51 Correct 284 ms 21048 KB Output is correct
52 Correct 70 ms 8696 KB Output is correct
53 Correct 75 ms 8696 KB Output is correct
54 Correct 18 ms 3452 KB Output is correct
55 Correct 333 ms 25088 KB Output is correct
56 Correct 37 ms 6016 KB Output is correct
57 Correct 73 ms 8700 KB Output is correct
58 Correct 93 ms 11380 KB Output is correct
59 Correct 38 ms 6016 KB Output is correct
60 Correct 42 ms 6144 KB Output is correct
61 Correct 97 ms 11380 KB Output is correct
62 Correct 63 ms 8696 KB Output is correct
63 Correct 131 ms 13168 KB Output is correct
64 Correct 38 ms 6016 KB Output is correct
65 Correct 195 ms 15868 KB Output is correct
66 Correct 64 ms 8696 KB Output is correct
67 Correct 128 ms 13168 KB Output is correct
68 Correct 169 ms 15088 KB Output is correct
69 Correct 181 ms 15728 KB Output is correct
70 Correct 62 ms 8652 KB Output is correct
71 Correct 163 ms 15092 KB Output is correct
72 Correct 134 ms 12652 KB Output is correct
73 Correct 210 ms 17648 KB Output is correct
74 Correct 60 ms 8696 KB Output is correct
75 Correct 59 ms 8440 KB Output is correct
76 Correct 138 ms 12784 KB Output is correct
77 Correct 204 ms 17520 KB Output is correct
78 Correct 87 ms 10104 KB Output is correct
79 Correct 59 ms 8440 KB Output is correct
80 Correct 33 ms 5504 KB Output is correct
81 Correct 83 ms 10104 KB Output is correct
82 Correct 146 ms 14448 KB Output is correct
83 Correct 33 ms 5504 KB Output is correct
84 Correct 141 ms 14448 KB Output is correct