PTA: 点赞狂魔

题目

输入样例:
5
bob 11 101 102 103 104 105 106 107 108 108 107 107
peter 8 1 2 3 4 3 2 5 1
chris 12 1 2 3 4 5 6 7 8 9 1 2 3
john 10 8 7 6 5 4 3 2 1 7 5
jack 9 6 7 8 9 10 11 12 13 14
输出样例:
jack chris john

代码

#include <cstdio>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <cstring>
#include <algorithm>

using namespace std;
map<string, set<int> > mp;
struct P{
   char name[10];
   int size = 0;
   int cnt = 0;
};

bool cmp(const P& l, const P& r) {
   int sl = l.size, sr = r.size;
   if(sl != sr) {
       return sl > sr;
   }
   return l.cnt < r.cnt;
}

int main(void)
{
   freopen("in.txt", "r", stdin);
   vector<P> vec;
   int N, label; char str[10];
   vec.reserve(105);

   scanf("%d", &N);
   set<int> s;
   int x;
   for(int i = 0; i < N; ++i) {
       s.clear();
       scanf("%s", str);
       strcpy(vec[i].name, str);
       scanf("%d", &x);
       while(x--) {
           scanf("%d", &label);
           s.insert(label);
           ++vec[i].cnt;
       }
       vec[i].size = s.size();
   }

   sort(vec.begin(), vec.begin()+N+1, cmp);

   bool flag = true;
   int t = min(N, 3);
   for(int i = 0; i < 3; ++i) {
       if(flag) flag = false;
       else printf(" ");
       if(i >= t) printf("-");
       else printf("%s", vec[i].name);
   }

   return 0;
}
  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值