L1-020 帅到没朋友
https://pintia.cn/problem-sets/994805046380707840/exam/problems/994805117167976448
#include<iostream> using namespace std; const int MAX = 1e6+5; int n,q1,x,q2,tmp;//n个朋友圈 int a[MAX],cnt=0;//cnt用于控制格式化输出 bool handsome_flag=false; int main() { cin>>n; while (n--) { scanf("%d",&q1); for (int i = 0; i < q1; i++) { scanf("%d",&x); if(q1>1) { a[x]=1; } } } scanf("%d",&q2);//q2个询问 for(int i=0;i<q2;i++) { scanf("%d",&tmp); if (a[tmp]==0) { cnt++; handsome_flag=true; if (cnt==1) { printf("%05d",tmp); }else if (cnt>1) { printf(" %05d",tmp); } a[tmp]=1;//处理重复询问 } } if (!handsome_flag) { printf("No one is handsome"); } return 0; } //坑:ID号从00000到99999,都是5位数,输出需要%05d
posted on 2023-03-09 16:05 ShinnyBlue 阅读(9) 评论(0) 收藏 举报
浙公网安备 33010602011771号