Submission #744091

# Submission time Handle Problem Language Result Execution time Memory
744091 2023-05-18T08:00:52 Z MilosMilutinovic Political Development (BOI17_politicaldevelopment) C++14
0 / 100
3000 ms 2788 KB
#include <bits/stdc++.h>
using namespace std;
 
int n,k,id[50005];
vector<int> g[50005];
 
signed main()
{
    scanf("%d%d",&n,&k);
    for(int d,i=0;i<n;i++)
    {
        scanf("%d",&d);
        for(int x,j=0;j<d;j++)
        {
            scanf("%d",&x);
            g[i].push_back(x);
            g[x].push_back(i);
        }
    }
    for(int i=0;i<n;i++) id[i]=-1;
    int ans=1;
    for(int i=0;i<n;i++)
    {
        int deg=(int)g[i].size();
        for(int j=0;j<deg;j++) id[g[i][j]]=j+1;
        id[i]=0;      
        deg++;
        vector<int> a;
        for(int x:g[i])
        {
            int f=(1<<id[x]);
            for(int y:g[x]) if(id[y]!=-1) f+=(1<<id[y]);
            a.push_back(f);
        }
        for(int mask=0;mask<(1<<deg);mask++)
        {
            bool ok=true;
            for(int j=0;j<deg;j++) if(mask>>j&1) if((mask&a[j])!=mask) ok=false;
            if(ok) ans=max(ans,__builtin_popcount(mask)+1);
        }
        for(int j=0;j<deg;j++) id[g[i][j]]=-1;
    }
    printf("%d\n",ans);
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:9:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
    9 |     scanf("%d%d",&n,&k);
      |     ~~~~~^~~~~~~~~~~~~~
politicaldevelopment.cpp:12:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   12 |         scanf("%d",&d);
      |         ~~~~~^~~~~~~~~
politicaldevelopment.cpp:15:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   15 |             scanf("%d",&x);
      |             ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1480 KB Output is correct
3 Execution timed out 3082 ms 1620 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1480 KB Output is correct
3 Execution timed out 3082 ms 1620 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 3 ms 2788 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1480 KB Output is correct
3 Execution timed out 3082 ms 1620 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1480 KB Output is correct
3 Execution timed out 3082 ms 1620 KB Time limit exceeded
4 Halted 0 ms 0 KB -