跳到正文

题解

题解 P5886 【Hello, 2020!】

gyh20约 1 分钟
原文
文章信息与版本

文章信息

收录
2026年6月14日
更新
2026年6月14日
篇幅
约 1 分钟
获赞
4
题目
P5886

版本

  1. v1当前

读过题目,我们可以发现,如果一个人是第一,那么所有判断他为第一的评委是对的,其他所有人都是错的。所以只需要判断认为一个人为第一是否恰好为pp个即可。

代码如下:

C++
#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);
}
原文