当前位置:网站首页>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]);
}
}
边栏推荐
- Deveco studio Hongmeng app access network detailed process (js)
- debian 10 nat 与路由转发
- 【博学谷学习记录】超强总结,用心分享 | 软件测试 接口测试基础
- np.isnan()
- 2022年比若依更香的开源项目
- Scientific research reagent DMPE-PEG-Mal dimyristoylphosphatidylethanolamine-polyethylene glycol-maleimide
- C语言 结构体定义方法
- Redis simple study notes
- How to check whether a table is locked in mysql
- Chemical reagent Phospholipid-polyethylene glycol-hydroxyl, DSPE-PEG-OH, DSPE-PEG-Hydroxyl, MW: 5000
猜你喜欢
Chapter 10 Clustering
DSPE-PEG-Silane, DSPE-PEG-SIL, phospholipid-polyethylene glycol-silane modified active group
DSPE-PEG-DBCO 磷脂-聚乙二醇-二苯并环辛炔 一种线性杂双官能聚乙二醇化试剂
DSPE-PEG-PDP, DSPE-PEG-OPSS, phospholipid-polyethylene glycol-mercaptopyridine supply, MW: 5000
知识工程作业2:知识工程相关领域介绍
Amazon sellers how to improve the conversion
网址URL
MySQL中字符串比较大小(日期字符串比较问题)
Debian 10 NTP Service Configuration
Redis简单学习笔记
随机推荐
钟表刻度线
骨架效果 之高级渐变,适用图片等待时
Phospholipid-Polyethylene Glycol-Aldehyde DSPE-PEG-Aldehyde DSPE-PEG-CHO MW: 5000
parser = argparse.ArgumentParser() parsing
subprocess.CalledProcessError: Command ‘pip install ‘thop‘‘ returned non-zero exit status 1.
@Configuration详解
SSM integration
Week 7 Review
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
Phospholipid-polyethylene glycol-targeted neovascularization targeting peptide APRPG, DSPE-PEG-APRPG
UserWarning:火炬。meshgrid:在以后的版本中,它将被要求通过索引ing argu
【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?
mysql中exists的用法详解
MySQL分库分表
Error in render: “TypeError: Cannot read properties of null (reading ‘0‘)“ 报错解决方案
STM32 map文件解析
语义分割标签即像素值的巨坑,transforms.ToTensor()的错误使用
URL模块
Phospholipid-polyethylene glycol-azide, DSPE-PEG-Azide, DSPE-PEG-N3, MW: 5000
@Autowired与@Resource区别