Most Popular FriendProblem code: LOKBIL |
All submissions for this problem are available.
Anna Hazare is a well known social activist in India.On 5th April, 2011 he started "Lokpal Bill movement".
Chef is very excited about this movement. He is thinking of contributing to it. He gathers his cook-herd and starts thinking about how our community can contribute to this.
All of them are excited about this too, but no one could come up with any idea. Cooks were slightly disappointed with this and went to consult their friends.
One of the geekiest friend gave them the idea of spreading knowledge through Facebook. But we do not want to spam people's wall. So our cook came up with the idea of dividing Facebook users into small friend groups and then identify the most popular friend in each group and post on his / her wall. They started dividing users into groups of friends and identifying the most popular amongst them.
The notoriety of a friend is defined as the averaged distance from all the other friends in his / her group. This measure considers the friend himself, and the trivial distance of '0' that he / she has with himself / herself.
The most popular friend in a group is the friend whose notoriety is least among all the friends in the group.
Distance between X and Y is defined as follows:
Minimum number of profiles that X needs to visit for reaching Y's profile(Including Y's profile). X can open only those profiles which are in the friend list of the current opened profile. For Example:
- Suppose A is friend of B.
- B has two friends C and D.
- E is a friend of D.
Now, the distance between A and B is 1, A and C is 2, C and E is 3.
So, one of our smart cooks took the responsibility of identifying the most popular friend in each group and others will go to persuade them for posting. This cheeky fellow knows that he can release his burden by giving this task as a long contest problem.
Now, he is asking you to write a program to identify the most popular friend among all the friends in each group. Also, our smart cook wants to know the average distance of everyone from the most popular friend.
Input
Friends in a group are labelled with numbers to hide their Facebook identity. The first line of input contains the number of groups in which users are divided. First line of each group contains the number of friends that belong to that group. ith line of each group contains the space separated friend list of 'i'. You are assured that each friend's profile can be accessed by the profile of every other friend by following some sequence of profile visits.
Output
Your output contains the most popular friend name label along with the average distance (space separated) from all other friends (including himself / herself) in six digits of precision. There might be multiple most popular friend, in that case output the friend labelled with least number.
Note:
Each person in a group have atleast one friend and he/she cannot be in his/her own friend list.
Number of friends in a group cannot be more than 100.
There are atmost 100 groups.
Example
Input: 1 6 3 5 1 4 3 5 6 2 4 6 4 5 Output: 4 1.166667
| Author: | ashwin_jain |
| Date Added: | 14-06-2011 |
| Time Limit: | 1 sec |
| Source Limit: | 50000 Bytes |
| Languages: | ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.0.0-8, CPP 4.3.2, CS2, D, ERL, F#, FORT, GO, HASK, ICK, ICON, JAR, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.1.2, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC |
Comments

Fetching successful submissions

sumone plz explain the
@skygar: ith line lists all
@praveen: thanks
any one can describe the
what we hav to print if there
Its written in the last line
am new to codechef can anyone
You have bug in tests - for
I absolutely agree with
I also agree with EgorK.
Thanx Egork , u saved some of
in the sample input, user 5
@admin: all the groups will
plz anyone describe testcase
Is friendship mutual?
wot is 3 5 1 4 3 5 6 2 4
yes, the test cases are not
Is friendship mutual? From
@pratikmoona yes
Must we put away unuseful
plz explain d test case after
after 1 that 6 indicates
sorry got it
I don't have much issues with
Also I was wondering why the
What is the minimum number of
@ EgorK : "You have bug in
@login_test: What is the
@login_test:::the minimum
@ admin::I believe Java judge
I think I have problems with
(There are new lines instead
(And only after the "float"
Thank you! In a group with
does the label of friends in
seperate output for each
@ all : 1 3 '1 2 3' '1 2
Sorry for late replies.
Getting wrong answer. What
Can input lines have spaces
@prakash1529 : I think it
ppl please post your test
@victorjavadore: Hey thanks a
@baruntar: Your output for
Hey, it is mentioned that
@rraahhuul We can take the
can we see the test cases for
@rrahuuul : '\n' is the
is it possible that distances
@amnsinghl::Read the last
output for different groups
Getting tle..wondering if bfs
Getting wrong answer. Cannot
can I get the test case which
Yea.. I got the bug.
Hello, I have been trying to
What is the meaning of the
hi,my submission id is
@admin Can we actually use
FOR SUBMISSION IN JAVA - MOST
hmm...generated a100*100
@ all : 1 3 '2 3' '1 3' '1 2'
@tsubhasis:Infact i got same
hey what will be the distance
@rijin It is 1 0.666667,
@ambu : thx, but its all
@rijin "There might be
Fed up of getting WA. Formed
@hpahuja the graph is
@ambujpandey try taking input
I think test cases have been
@ambuj: its backslash n in
@KK123 Thanks, but still
@ambuj : use ideone.com to
is it possible to solve this
Beware of the hideous extra
what is output format for
rj_rohit -> Incorrect
@admin: can you tell me
@ashwin_adm Couldn't find the
@aswin_admin: what is the run
In the question we have "Now,
@urbaddy: Yes , it is
@ashwin_adm:thanks for your
@admin:can u please give
@bb_1: Explain the test case,
plz suggest some typical test
if anyone cud tell the prob
I Need Bit Help In taking
@kooljay : read KK123 @ 4 Jul
@rijin : Thanks :)
Are you certain there isn't a
i just submitted @pratikmoona
I have tried reading the
And I have also tried it with
@bittu_it: Refer
@Admin: I know it is not
@migdal.@hpahuja or
I am pretty sure that i I
@KK123 thanx buddy,your post
@mkagenious sorry it's u
@Admin: Could you please go
@admin plz help me i m
@admin bug sorted out sorry
gets() is working fine for
plz help! if friends of 1 are
Hi ,I have been trying this
im sorry for double posting
@amnsinghi: Yes, 1 should be
can someone just c my code
@hack_world: no one is going
@admin : i am getting the
I finally lowered my
one minor doubt : output is
@anshulgoyal: The output
@hack_world: thanx for reply
Can someone check my code and
what would be the distance
Guys plz can u post ur test
help somebody please....I am
its backslash n in the
@admin: Can you plz let me
i'm getting tle.i'm using
ok my input problem is solved
hey admin I am getting tle on
hey what does tle