当前位置:网站首页>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
边栏推荐
- LeetCode 447. Number of boomerangs (permutation and combination problem)
- How to classify proxy IP?
- PTA: 浪漫倒影 [二叉树重建] [深度优先遍历]
- 001_redis设置存活时间
- Is it better to use a physical machine or a virtual machine to build a website?
- Implementation of Base64 encoding / decoding in C language
- Virtual serial port function of j-link V9 using skills
- Communication summary between MCU and 4G module (EC20)
- Heap overflow of kernel PWN basic tutorial
- How to configure iptables to realize local port forwarding
猜你喜欢

Under the pressure of sales, domestic mobile phones began to reduce prices, but they haven't put down their final face

每日一题(2022-04-22)——旋转函数
![leetcode:27. Remove element [count remove]](/img/af/e5cd9ef8dc43aab4ddf016600ffc4a.png)
leetcode:27. Remove element [count remove]

【Chrome扩展程序】content_script的跨域问题

有哪些业务会用到物理服务器?

【dpdk】10. Dpdk DNS learning notes

Leetcode39 combined sum

Talk about biology live broadcast: Dr. Wang Ziyuan, a lake view biology, exploring hepatitis B with gene therapy

A simple and open source navigation website source code
![[assembly language] understand](/img/73/2483bca93714e378ff5eef18bddcd1.jpg)
[assembly language] understand "stack" from the lowest point of view
随机推荐
使用代理IP是需要注意什么?
What are the common proxy IP problems?
App optimization and advanced scoreboard Part 2 [Mui + flask + mongodb]
On LAN
今天终于会写System.out.println()了
MySQL C language connection
从开源爱好者到 Apache 董事,一共分几步?
搭建网站是用物理机还是云主机好?
How to write the resume of Software Test Engineer so that HR can see it?
在使用代理IP前需要了解哪些分类?
Analyze the three functions of static proxy IP.
[nk]牛客月赛48 D
一加一为什么等于二
[assembly language] understand "stack" from the lowest point of view
tp6阿里云短信 window 报 cURL error 60: SSL certificate problem: unable to get local issuer certificate
PHP & laravel & master several ways of generating token by API and some precautions (PIT)
What is a makefile file?
Introduction to micro build low code zero Foundation (lesson 2)
假如404页面是这样的 | 每日趣闻
New book recommendation - IPv6 technology and application (Ruijie version)