#include <malloc.h> #include <cstdio> //<n true; bool distance(int left, int right, int length, int n)
{ bool flag = false; if((right-left)<=n || (left+length-right)<=n)
flag = true; return flag;
} int main()
{ int m, n, c;
scanf("%d%d%d",&m,&n,&c); int** input = (int**)malloc(sizeof(int*)*m); int* length = (int*)malloc(sizeof(int)*m); bool color[c][m]; for(int i = 0; i<c;i++) for(int j=0;j<m;j++)
color[i][j] = false; for(int i=0;i<m;i++)
{
scanf("%d",&length[i]); int* temp = (int*)malloc(sizeof(int)*length[i]);
input[i] = temp; for(int j=0;j<length[i];j++)
{
scanf("%d",&input[i][j]);
color[input[i][j]-1][i] = true;
}
} int result = 0; for(int i=0;i<c;i++)
{ int index = 0; int pre = 0; while (!color[i][index])
index++;
pre = index; for(int j = pre+1;j<m;j++)
{ if(color[i][j])
{ if(distance(pre,j,m,n))
{
result++; break;
} else {
pre = j;
}
}
}
}
printf("%d\n",result); return 0;
}
#字节跳动#