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;
}
有问题欢迎在评论区提出!
22 条评论
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
似乎是的,一开始没配好,现在都禁掉了
Pragmatic Play · 2023年8月21日 下午12:10
I’m often to blogging and i really appreciate your content. The article has actually peaks my interest. I’m going to bookmark your web site and maintain checking for brand spanking new information.
Demo Slot · 2023年8月23日 上午4:26
I very delighted to find this internet site on bing, just what I was searching for as well saved to fav
Slot Demo · 2023年8月24日 上午9:18
This was beautiful Admin. Thank you for your reflections.
Slot Demo · 2023年8月25日 上午10:55
You’re so awesome! I don’t believe I have read a single thing like that before. So great to find someone with some original thoughts on this topic. Really.. thank you for starting this up. This website is something that is needed on the internet, someone with a little originality!
Slot Demo PG Soft · 2023年8月30日 上午7:36
very informative articles or reviews at this time.
Demo PG · 2023年8月31日 上午3:55
I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will
Prediksi SDY Akurat · 2023年8月31日 上午5:42
Thanks for a marvelous posting! I genuinely enjoyed reading it, you are a great author.I will always bookmark your blog and will often come back down the road. I want to encourage continue your great job, have a nice weekend!
Slot Online · 2023年9月1日 上午5:26
I do not even understand how I ended up here, but I assumed this publish used to be great
Bambu 4d · 2023年9月2日 上午2:54
I truly appreciate your technique of writing a blog. I added it to my bookmark site list and will
Bambu4d Togel · 2023年9月7日 上午2:52
Try to slowly read the articles on this website, don’t just comment, I think the posts on this page are very helpful, because I understand the intent of the author of this article.
Nolimit City · 2023年9月8日 上午4:10
naturally like your web site however you need to take a look at the spelling on several of your posts. A number of them are rife with spelling problems and I find it very bothersome to tell the truth on the other hand I will surely come again again.
Aplikasi Bambu4d · 2023年9月9日 上午12:23
Yeah bookmaking this wasn’t a risky decision outstanding post!.