当前位置:网站首页>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]);
}
}
边栏推荐
- C语言 内联函数
- C语言 0长度数组/柔性数组
- 磷脂-聚乙二醇-巯基,DSPE-PEG-Thiol,DSPE-PEG-SH,MW:5000
- 【装机】老毛桃的安装及使用
- Knowledge Engineering Assignment 2: Introduction to Knowledge Engineering Related Fields
- meime模块
- IndexError: only integers, slices (`:`), ellipsis (`...`), numpy.newaxis (`None`) and integer or boo
- C语言 void和void *(无类型指针)
- Basic usage of Monaco Editor
- Debian 10 NTP 服务配置
猜你喜欢

npm--package.json---require

C语言的变长数组

ModuleNotFoundError No module named ‘xxx‘可能的解决方案大全

subprocess.CalledProcessError: Command 'pip install 'thop'' returned non-zero exit status 1.

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

语义分割标签即像素值的巨坑,transforms.ToTensor()的错误使用

STM32 map文件解析

PCL—point cloud data segmentation

@Configuration详解

AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘
随机推荐
Problems when yolov5 calls ip camera
FreeRTOS内核详解(1) —— 临界段保护原理
Error: with open(txt_path,'r') as f: FileNotFoundError: [Errno 2] No such file or directory:
3 minutes to take you to understand WeChat applet development
require模块化语法
Debian 10 NTP 服务配置
subprocess.CalledProcessError: Command 'pip install 'thop'' returned non-zero exit status 1.
MySql创建数据表
第一篇博客
磷脂-聚乙二醇-靶向新生血管靶向肽APRPG,DSPE-PEG-APRPG
DSPE-PEG-Silane, DSPE-PEG-SIL, phospholipid-polyethylene glycol-silane modified active group
subprocess.CalledProcessError: Command ‘pip install ‘thop‘‘ returned non-zero exit status 1.
C语言 结构体定义方法
kettle 安装与配置
PCL—point cloud data segmentation
parser = argparse.ArgumentParser() parsing
ModuleNotFoundError No module named 'xxx' possible solutions
【程序人生】做了多年的运维,靠什么转行拿下12K+年终奖的薪资?
JJWT tool class
C语言 十六进制整数字符串转十进制整数