当前位置:网站首页>L1-020 帅到没朋友 (20分)
L1-020 帅到没朋友 (20分)
2022-08-02 03:22:00 【寒江飞冰】
L1-020 帅到没朋友 (20分)
当芸芸众生忙着在朋友圈中发照片的时候,总有一些人因为太帅而没有朋友。本题就要求你找出那些帅到没有朋友的人。
输入格式:
输入第一行给出一个正整数N(≤100),是已知朋友圈的个数;随后N行,每行首先给出一个正整数K(≤1000),为朋友圈中的人数,然后列出一个朋友圈内的所有人——为方便起见,每人对应一个ID号,为5位数字(从00000到99999),ID间以空格分隔;之后给出一个正整数M(≤10000),为待查询的人数;随后一行中列出M个待查询的ID,以空格分隔。
注意:没有朋友的人可以是根本没安装“朋友圈”,也可以是只有自己一个人在朋友圈的人。虽然有个别自恋狂会自己把自己反复加进朋友圈,但题目保证所有K超过1的朋友圈里都至少有2个不同的人。
输出格式:
按输入的顺序输出那些帅到没朋友的人。ID间用1个空格分隔,行的首尾不得有多余空格。如果没有人太帅,则输出No one is handsome。
注意:同一个人可以被查询多次,但只输出一次。
输入样例1:
3
3 11111 22222 55555
2 33333 44444
4 55555 66666 99999 77777
8
55555 44444 10000 88888 22222 11111 23333 88888
输出样例1:
10000 88888 23333
输入样例2:
3
3 11111 22222 55555
2 33333 44444
4 55555 66666 99999 77777
4
55555 44444 22222 11111
输出样例2:
No one is handsome
思路:
第一个点是题目理解问题。我看题的时候看不懂下面这句话,以为没用就略过了,其实这就是第三个测试点。
没有朋友的人可以是根本没安装“朋友圈”,也可以是只有自己一个人在朋友圈的人。
前半部分就是说没有出现在上面的账号就是要输出的,后半部分就是说假如输入的时候出现k==1,那后面出现的账号同样是没有朋友的,除非在后面的输入中被改变。
第二点就是问题的这一句话
每人对应一个ID号,为5位数字(从00000到99999)
这句话也是第四个测试点与第五个测试点成功的关键,在我们输出过程中就要考虑一个数值不满足五位数的情况下,应该用%05d来补0
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
set<int> a;
for(int i=0;i<n;i++)
{
int k;
cin>>k;
for(int j=0;j<k;j++)
{
int t;
cin>>t;
if(k!=1)
{
a.insert(t);
}
}
}
int m;
cin>>m;
vector<int> b;
for(int i=0;i<m;i++)
{
int t;
cin>>t;
int flag=0;
for(int i=0;i<b.size();i++)
{
if(b[i]==t)
{
flag=1;
break;
}
}
if(flag==0)
{
b.push_back(t);
}
}
vector<int> c;
for(int i=0;i<b.size();i++)
{
if(a.count(b[i])==0)
{
c.push_back(b[i]);
}
}
if(c.size()==0)
{
cout<<"No one is handsome";
}
else{
for(int i=0;i<c.size()-1;i++)
{
printf("%05d ",c[i]);
}
printf("%05d",c[c.size()-1]);
}
}
边栏推荐
- 【装机】老毛桃的安装及使用
- 相对路径和绝对路径
- mysql创建表
- ModuleNotFoundError No module named 'xxx' possible solutions
- STM32 map文件解析
- IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
- AttributeError: Can‘t get attribute ‘SPPF‘ on <module ‘models.common‘ from ‘/yolov5-5.0/models/commo
- ssm various configuration templates
- 化学试剂磷脂-聚乙二醇-羟基,DSPE-PEG-OH,DSPE-PEG-Hydroxyl,MW:5000
- 磷脂-聚乙二醇-酰肼,DSPE-PEG-Hydrazide,DSPE-PEG-HZ,MW:5000
猜你喜欢

DSPE-PEG-DBCO 磷脂-聚乙二醇-二苯并环辛炔 一种线性杂双官能聚乙二醇化试剂

啃瓜记录第一天

String comparison size in MySQL (date string comparison problem)

Cut out web icons through PS 2021

【我的创作纪念日】 3周年

通过PS 2021 将网页图标抠下来

磷脂-聚乙二醇-巯基,DSPE-PEG-Thiol,DSPE-PEG-SH,MW:5000

PCL—点云数据分割

Redis简单学习笔记

Phospholipid-polyethylene glycol-targeted neovascularization targeting peptide APRPG, DSPE-PEG-APRPG
随机推荐
JJWT工具类
@Configuration详解
AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
科研试剂DMPE-PEG-Mal 二肉豆蔻酰磷脂酰乙醇胺-聚乙二醇-马来酰亚胺
C语言的变长数组
@Autowired注解的使用
kettle 安装与配置
debian 10 nat 与路由转发
UserWarning:火炬。meshgrid:在以后的版本中,它将被要求通过索引ing argu
【深度学习】从LeNet-5识别手写数字入门深度学习
Week 7 Review
Phospholipid-polyethylene glycol-azide, DSPE-PEG-Azide, DSPE-PEG-N3, MW: 5000
subprocess.CalledProcessError: Command 'pip install 'thop'' returned non-zero exit status 1.
np.isnan ()
PCL—点云数据分割
The usage of json type field in mysql
String comparison size in MySQL (date string comparison problem)
subprocess.CalledProcessError: Command ‘pip install ‘thop‘‘ returned non-zero exit status 1.
啃瓜记录又一天