当前位置:网站首页>PTA: praise the crazy devil
PTA: praise the crazy devil
2022-04-23 02:08:00 【JackDawn!?】
subject 
sample input :
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
sample output :
jack chris john
Code
#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://yzsam.com/2022/04/202204230205355260.html
边栏推荐
- 一加一为什么等于二
- EBS:PO_ EMPLOYEE_ HIERARCHIES_ ALL
- 010_StringRedisTemplate
- Is the availability of proxy IP equal to the efficiency of proxy IP?
- 012_ Access denied for user ‘root‘@‘localhost‘ (using password: YES)
- What should I pay attention to when using proxy IP?
- Is CICC fortune a company with CICC? Is it safe
- 如何设置电脑ip?
- Tp6 Alibaba cloud SMS window reports curl error 60: SSL certificate problem: unable to get local issuer certificate
- 006_redis_SortedSet类型
猜你喜欢
我国科学家揭示突破水稻产量瓶颈新机制
89 logistic回歸用戶畫像用戶響應度預測
Introduction to micro build low code zero Foundation (lesson 2)
每日一题(2022-04-21)——山羊拉丁文
Is the availability of proxy IP equal to the efficiency of proxy IP?
Campus transfer second-hand market source code
Shardingsphere sub database and sub table
leetcode:27. Remove element [count remove]
011_RedisTemplate操作Hash
有哪些常见的代理ip问题?
随机推荐
配置iptables实现本地端口转发的方法详解
hyperscan --- 1
Tp6 Alibaba cloud SMS window reports curl error 60: SSL certificate problem: unable to get local issuer certificate
How to call out services in idea and display the startup class in services
Is it better to use a physical machine or a virtual machine to build a website?
Multithreading technology core
今天终于会写System.out.println()了
What is BGP server and what are its advantages?
Wechat public platform test number application, authorized login function and single sign on using hbuilder X and wechat developer tools
Tp6 Alibaba Cloud SMS Window message Curl Error 60: SSL Certificate Problem: Unable to get local issuer Certificate
【汇编语言】从最底层的角度理解“堆栈”
Communication summary between MCU and 4G module (EC20)
How to initialize "naming and surname" in C language
什么是bgp服务器,有哪些优势?
tp6阿裏雲短信 window 報 cURL error 60: SSL certificate problem: unable to get local issuer certificate
002_Redis_String类型常见的操作命令
从开源爱好者到 Apache 董事,一共分几步?
Chinese scientists reveal a new mechanism for breaking through the bottleneck of rice yield
小程序 读取文件
如何设置电脑ip?