当前位置:网站首页>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
边栏推荐
- Chinese scientists reveal a new mechanism for breaking through the bottleneck of rice yield
- Cc2541 emulator CC debugger tutorial
- What is an API interface?
- tp6阿裏雲短信 window 報 cURL error 60: SSL certificate problem: unable to get local issuer certificate
- [hands on learning] network depth v2.1 Sequence model
- 都是做全屋智能的,Aqara和HomeKit到底有什么不同?
- PTA: 浪漫倒影 [二叉树重建] [深度优先遍历]
- 有哪些常见的代理ip问题?
- Why is one plus one equal to two
- What problems will you encounter when dialing VPS?
猜你喜欢

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

Shardingsphere sub database and sub table

Open3d point cloud processing

ThinkPHP kernel development blind box mall source code v2 0 docking easy payment / Alibaba cloud SMS / qiniu cloud storage

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

001_redis设置存活时间

R language advanced | generalized vector and attribute analysis

Leetcode46 Full Permutation

What business scenarios will the BGP server be used in?

Dynamic batch processing and static batch processing of unity
随机推荐
006_redis_SortedSet类型
Common formatting problems after word writing
Hyperscan -- 2 compilation
2018 China Collegiate Programming Contest - Guilin Site J. stone game
Analyze the three functions of static proxy IP.
How to classify proxy IP?
都是做全屋智能的,Aqara和HomeKit到底有什么不同?
Is the sinking coffee industry a false prosperity or the eve of a broken situation?
Quel est le fichier makefile?
010_StringRedisTemplate
What should I pay attention to when using proxy IP?
How to choose a good dial-up server?
Startup of openstack service
Micro build low code zero foundation introductory course
什么是bgp服务器,有哪些优势?
What problems will you encounter when dialing VPS?
What categories do you need to know before using proxy IP?
2018 China Collegiate Programming Contest - Guilin Site J. stone game
Flink real-time data warehouse project - Design and implementation of DWS layer
Implementation of Base64 encoding / decoding in C language