A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » C
  • » Help in Solving this problem

#1 2008-09-03 03:23 PM


Re: Help in Solving this problem

Ariel Kournikova a psychologist is trying to find the reason behind lying. For this purpose she goes to different kitty parties and asks the same question to all the ladies present in each party. The question is about their date of birth. During her visits to different parties, she meets many ladies who were present in previous parties too but when she asks them the same question, some of them give different answers and hence are lying to her (just to hide their real age). Later Ariel Kournikova invite all the ladies she had ever met in the kitty parties to her home and request them to sit in the form of a square matrix of row = column = square root of total number of ladies Ariel Kournikova had met, in row major form and in alphabetic order of their name (for example sweata < sweta , rajesh < rajnesh, ankit < ankita). Now for her psychometric test, she wants a group of ladies from that matrix who are liars and are adjacent to each other in maximum possible way. Your task is to assist Ariel Kournikova in finding the biggest group of liars from that matrix such that each and every liar of that group has at least two liars of the group adjacent to her (adjacent means either up, down, left or right).
1. Total number of different ladies Ariel Kournikova met in different kitty parties will always be a perfect square.
2. A lady is a liar if she tells different dates of their birth in at least two parties.
3. The name of the ladies will be of single word only.
4. The length of the word of ladies name will be of less than 30 letters.
5. Diagonals are not considered as adjacent.
INPUT FORMAT : number of test cases (0 < n < 100) <blank line> number of parties visited by Ariel Kournikova ( 0 <= p <=10000 ) <blank line> party 1 name of ladies and their date of birth in first party with space of two between name and date of birth (>=1000000) <blank line> party 2 name of ladies and their date of birth in second party with space of two between name and date of birth <blank line> and so on till n party <blank line> same format for 2nd test case and so on for other OUTPUT FORMAT : case 1 the number of liars in the group case 2 the number of liars in the group and so on
party 1
ankita 25.12.1987
neha 25.10.1986 megha 18.9.1985
ruby 12.12.1979
urvasi 18.2.1977
kirti 13.3.1978

party 2
ankita 25.12.1987
anjali 17.8.1988
devika 13.2.1986
ruby 12.12.1978
saroj 12.2.1967

party 3
megha 9.9.1979
neha 12.12.1979
kirti 25.12.1987
urvasi 18.2.1977
saroj 2.2.1967 2
party 1
anny 12.1.1974
party 2
anny 12.2.1974

OUTPUT FILE : case 1 4 case 2 0

  • Index
  • » C
  • » Help in Solving this problem

Board footer

Powered by FluxBB