CF441A Valera and Antique Items题面
题面描述
有 n 个人,第 i 个人有 k[i] 个数。第 i 个人的第 j 个数的大小为 a[i][j],你拥有一个数大小为 v ,如果你的数 v 严格大于某人的至少一个数。那么认为你可以和这个人达成协议。
求你能和几个人达成协议,分别是哪几个。(答案按编号上升的顺序输出)
分析
题目里的翻译有一定迷惑性,理解后会发现此题很简单:
因为数据不大,我们可以直接对于每一个人暴力判断是否有一个数比给出的 v 小即可。
直接正着做下去,然后一旦能和一个人达成协议就统计,这样的话我们就不需要考虑答案要按编号上升的顺序输出了(因为直接找到的人就是按编号上升的顺序找的)。
完整代码
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e6+7;
ll read()
{
ll res=0,f=1;
char c=getchar();
while(!isdigit(c) && c!='-') c=getchar();
if(c=='-') f=-1,c=getchar();
while(isdigit(c)) res=(res<<1)+(res<<3)+c-48,c=getchar();
return res*f;
}
int tot,ans[maxn];
int main()
{
int n=read(),v=read();
for(int i=1;i<=n;i++)
{
int k=read(); //我们可以直接边读入边做
bool bl=0; //bl表示当前人是否能达成协议
for(int j=1;j<=k;j++)
{
int x=read();
if(x<v) bl=1; //注意题目要求严格大于
}
if(bl) ans[++tot]=i;
}
printf("%d\n",tot);
for(int i=1;i<=tot;i++) printf("%d ",ans[i]);
return 0;
}
有问题欢迎在评论区提出!
10 条评论
bursa escort · 2021年3月2日 上午9:01
By developing strong leg muscles, you will not only be able to shoot harder, but you will also be able to protect yourself from many of the common soccer injuries such as a torn hamstring or torn achilles. Adelina Rabi Benedix
Melon_Musk · 2021年3月2日 下午6:19
Unn,,,maybe I can’t understand what you mean.
erotik · 2021年3月2日 下午2:37
Sir, I believe you should go ahead and create the Youtube channel. Scarlet Esra Hardner
Melon_Musk · 2021年3月2日 下午6:23
Thank you?But I’m not very good at the Youtube channel.so,,, what should I do?
golf swing fundamentals · 2021年3月5日 下午3:25
A round of applause for your blog. Much thanks again. Cool. Jami Russ Anabella
shelldownloadorg.İndoxploit shell · 2021年3月13日 上午8:08
We are a group of volunteers and opening a new scheme in our community.
Your web site provided us with valuable information to work on. You have done a formidable job and
our entire community will be grateful to you.
shell-download · 2021年3月15日 上午1:38
Way cool! Some extremely valid points! I appreciate you penning this write-up and also the rest of the site is very good.
Türk takipçi satın al · 2021年3月16日 上午6:37
Takipçi satın almak sadece gelir elde etmek isteyen kişilerin değil hesaplarındaki
takipçi sayısını
yükselterek popüler bir profil oluşturmak isteyen kullanıcılarında tercih ettikleri bir yöntemdir
. Instagram fenomeni olmak için İnstagram takipçi sayınızı megatakip adresi ile güvenilir sekilde takipci alabilirsiniz
Jill·Stingray · 2021年8月26日 下午5:11
这评论是一堆机器人吗。。。
Melon_Musk · 2021年8月31日 下午3:32
似乎是的,一开始没配好,现在都禁掉了