题解 P5886 【Hello, 2020!】
读过题目,我们可以发现,如果一个人是第一,那么所有判断他为第一的评委是对的,其他所有人都是错的。所以只需要判断认为一个人为第一是否恰好为
代码如下:
#include<cstdio>
using namespace std;
#define re register
const int Mxdt=500;
inline char gc(){
static char buf[Mxdt],*p1=buf,*p2=buf;
return p1==p2&&(p2=(p1=buf)+fread(buf,1,Mxdt,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read()
{
int res=0;char ch=gc();
while(ch<'0'||ch>'9')ch=gc();
while(ch>='0'&&ch<='9')res=(res<<3)+(res<<1)+(ch^48),ch=gc();
return res;
}
int n,m,a[1000002],p,b,ans;
int main(){
n=read()+1;
m=read();
p=read();
while(--n){
b=read()+1;
while(--b){
++a[read()];
}
}
for(re int i=1;i<=m;++i)if(a[i]==p)++ans;
printf("%d\n",ans);
for(re int i=1;i<=m;++i)if(a[i]==p)printf("%d ",i);
}