Submission #744094

# Submission time Handle Problem Language Result Execution time Memory
744094 2023-05-18T08:03:19 Z MilosMilutinovic Political Development (BOI17_politicaldevelopment) C++14
0 / 100
3000 ms 1620 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;
        a.push_back((1<<deg)-1);
        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));
        }
        for(int j=0;j<deg-1;j++) id[g[i][j]]=-1; id[i]=-1;
    }
    printf("%d\n",ans);
}

Compilation message

politicaldevelopment.cpp: In function 'int main()':
politicaldevelopment.cpp:42:9: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   42 |         for(int j=0;j<deg-1;j++) id[g[i][j]]=-1; id[i]=-1;
      |         ^~~
politicaldevelopment.cpp:42:50: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   42 |         for(int j=0;j<deg-1;j++) id[g[i][j]]=-1; id[i]=-1;
      |                                                  ^~
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 1364 KB Output is correct
3 Execution timed out 3068 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 1364 KB Output is correct
3 Execution timed out 3068 ms 1620 KB Time limit exceeded
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1492 KB Output is correct
2 Incorrect 2 ms 1364 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1364 KB Output is correct
2 Correct 1 ms 1364 KB Output is correct
3 Execution timed out 3068 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 1364 KB Output is correct
3 Execution timed out 3068 ms 1620 KB Time limit exceeded
4 Halted 0 ms 0 KB -