7-8 likes a maniac (25 points)

Source: Internet
Author: User
Tags first row

There is a "like" feature on Weibo, and you can support your favorite blog post with a few likes. Each blog post has a label that describes its characteristics, and the type of post you like is also an indirect depiction of your features. However, there is a kind of person, they would like to see all the content of their own crazy brush the existence of the feeling, this kind of people are called "Point likes the demon". The labels they liked were very scattered and could not reflect the obvious characteristics. The subject asks you to write a program, by counting the number of different tags everyone likes, to find out the top 3 points like the crazy demon. Input Format:

The input gives a positive integer n (≤) in the first row, which is the number of users to be counted. Then n rows, each row lists a user's liking label. The format is "name K F 1⋯f K", where name is a non-empty user name of no more than 8 English lowercase letters, 1,f I (,) is the number of the attribute tag, we numbered all attribute labels from 1 to 107. The numbers are separated by a space. output Format:

Count the number of different tags everyone likes, find the top 3 of the largest number, and sequentially output their usernames in a row, separated by 1 spaces, with no extra spaces at the end of the line. If there is a side-by-side, the output label appears the average number of the smallest, the topic guarantees that such users are not tied. If there are less than 3 people, then the use of-the missing, such as Mike Jenny-means that only 2 people. Input Sample:

5
Bob One 101 102 103 104 1 106 107 108 108 107 107
Peter 8 2 3 4 3 2 5 1
Chris 12 1 2 3 4 5 6 7 8 9 1 2 3< C6/>john 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.
My Code:

 #include <iostream> #include <set> #include <string> #include <vector> #
Include<algorithm> using namespace std;
	struct Click {string name;
	int cnt;
	Double Ave;
Click (String Name1,int cnt1,double ave1): Name (NAME1), CNT (cnt1), ave (ave1) {}};
	int CMP (click A,click b) {if (a.cnt!=b.cnt) return a.cnt>b.cnt;
else return a.ave<b.ave;
	} int main () {vector<click>v;
	set<int>s[101];
	int i,j,x,y,z;
	String name;
	cin>>x;
		for (i=0;i<x;i++) {cin>>name>>y;
			for (j=0;j<y;j++) {cin>>z;
		S[i].insert (z);
	} v.push_back (Click (Name,s[i].size (), (double) y/(double) S[i].size ()));
	} sort (V.begin (), V.end (), CMP);
		for (i=0;i<3;i++) {if (i!=0) cout<< "";
		if (I<v.size ()) cout<<v[i].name;
	else cout<< '-';
} return 0; }

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.