SOCIALNE - Possible Friends
Josué, one of the undergraduate students in PUCMM, is developing a Social Network, but he is having difficulties in identifying the person that has more possible friends. Two persons are possible friends if they are not friends and they have at least one common friend, for example if person A is friend only to person B, and person B is friend of C, then, A and C are possible friends. You are about to help him in this task. Given the network table, you have to write a program that finds the person that has more possible friends, if more than one person matches this criteria, then select the one that comes first ( the one that has the lower ID).
The first line is T (1 ≤ T ≤ 1,000), the number of test cases, then T test cases follow.
Each test case consists in a 'Y' or 'N' square matrix(MxM) representing the friendship of the network, where M is the number of persons.
M (1 ≤ M ≤ 50)
The square matrix has M lines, each line has M characters.
The first line of the matrix corresponds to person 0, the next line to person 1, and so on.
On each line the leftmost character corresponds to person 0, the next character to person 1, and so on.
So if character j of the line i is 'Y', it means that person 'i' is a friend of 'j'.
For each person i, character i of line i will be 'N'.
For each i,j character j of line i will be the same as character i of line j.
For each test case, you have to output one line containing the ID of the person(0-based) that has more possible friends and the number of possible friends this person has, separated by a blank space.
AC in 1 go:-)
bahut tagda question really liked it!! first time missing that check condition...edited the code n AC in 2nd go!!
Problem setter is Naive. It's not mentioned but for case:
it's quite silly! using cin,cout gives TLE. Adding ios::sync_with_stdio(false); gives the same code AC!!!
Forgot to note this: "if more than one person matches this criteria, then select the one that comes first ( the one that has the lower ID)."
easy but implementation quite tricky
cant find mistake in my code...pls check 9948927
half century :)