当前位置:网站首页>PTA: 点赞狂魔
PTA: 点赞狂魔
2022-04-23 02:05:00 【JackDawn!?】
题目
输入样例:
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;
}
版权声明
本文为[JackDawn!?]所创,转载请带上原文链接,感谢
https://blog.csdn.net/apple_52296856/article/details/124315732
边栏推荐
猜你喜欢

MySQL basic record

Use of j-link RTT

89 régression logistique prédiction de la réponse de l'utilisateur à l'image de l'utilisateur

在使用代理IP前需要了解哪些分类?

A simple and open source navigation website source code

CC2541的仿真器CC Debugger使用教程

代理IP可用率是不是等同于代理IP的效率?

使用代理IP是需要注意什么?

Introduction to micro build low code zero Foundation (lesson 2)

Use Xdebug breakpoint debugging in postman
随机推荐
Introduction to esp32 Bluetooth controller API
The leader / teacher asks to fill in the EXCEL form document. How to edit the word / Excel file on the mobile phone and fill in the Excel / word electronic document?
RuntimeError: The size of tensor a (4) must match the size of tensor b (3) at non-singleton dimensio
[leetcode daily question] 396 Rotation function
Gray scale range corresponding to colors (red, yellow, green, blue, purple, pink, brick red and magenta) in HSV color space
Batch multiple files into one hex
如何选择一台好的拨号服务器?
浅析静态代理ip的三大作用。
【动手学深度学习V2】循环神经网络-1.序列模型
Network jitter tool clumsy
leetcode:27. Remove element [count remove]
Quel est le fichier makefile?
How to initialize "naming and surname" in C language
php 2022年4月20面试题整理
Thinkphp内核开发盲盒商城源码v2.0 对接易支付/阿里云短信/七牛云存储
Is CICC fortune a state-owned enterprise and is it safe to open an account
[Dahua cloud native] micro service chapter - service mode of five-star hotels
2018 China Collegiate Programming Contest - Guilin Site J. stone game
Realize linear regression with tensorflow (including problems and solutions in the process)
[Leetcode每日一题]396. 旋转函数