CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Practice(medium) » Name Chopping

Name Chopping

Problem code: INSOMA4

  • Submit
  • All Submissions

All submissions for this problem are available.

In the hidden country of Lapatrecta, an age old custom was followed to ensure that no outsider ever entered their country undetected. The security measure, though simple, was an effective one. Every person born in Lapatrecta had the initials of all his forefathers included in front of his name. Every once in a while, certain families became very famous and the initials of their ancestors were dropped from the names of all their descendants. Thus, there existed a nice homogeneity in the names of the people of Lapatrecta.

Now, a royal ball was organized at the behest of the Queen of Lapatrecta and all citizens were cordially invited to the event. The ball was being held to chop off the initials of the ancestors of the most distinguished family of the country. The Queen set the following 2 criteria for determining the most distinguished family from amongst the invitees:

1. The family must have more than 1 member living.
2. The length of the ancestor list of the family must be as long as possible.

For example:

For 3 people:

APJQ Ravi

APJRS Rahul

PJQ Bharat




The following observations hold:

APJQ Ravi was of the same family as APJ Rahul but PJQ Bharat was not of the same family.

The length of the ancestor list for Ravi and Rahul was 3 whereas Bharat has an ancestor length of 0 as there is no other member of his family living. However, if there existed a person named PJ Varun, Bharat and Varun would both have an ancestor list length of 2.

As a member of the Royal Court of Lapatrecta, you have been entrusted the task of determining the length of the ancestor list that will be chopped off by the Queen. You will be provided data in the following format:

Input

Line 1: N – The number of people coming to the ball

Line 2-N+1: The initials list of all the people coming to the ball. No initials list is longer than 100 characters.

Output

Line 1: The length of the longest ancestor list.

Example

Input:
3
APJQ
APJRS
PJQ

Output:
3 

Author: admin
Date Added: 19-03-2009
Time Limit: 2 - 7 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, 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


  • Submit

Comments

  • Login or Register to post a comment.

sagar_jhobalia @ 22 Jun 2009 08:47 PM

the question isn't clear...pls giv an example with an explanation

is there any limit on the no

kshivi @ 1 Sep 2009 06:21 PM

is there any limit on the no of people that attend the ball?

 

Is the input restricted to

tuxcanfly @ 6 Sep 2009 08:57 PM

Is the input restricted to CAPS or can it be small and miXeD case??

Can be mixed.

admin @ 7 Sep 2009 02:22 PM

Can be mixed.

what is the maximum value of

vivek.cs.iitr @ 21 Nov 2009 01:30 AM

what is the maximum value of N ?

For N=10000, my code has

vivek.cs.iitr @ 21 Nov 2009 03:48 AM

For N=10000, my code has runtime well below 7 s.

so is it that N can be even higher than this, given it is being displayed as time limit exceeded.

Admin, I have solved this

sppraveen @ 23 Nov 2009 12:08 PM

Admin,

I have solved this problem. I could not see the submissions of others. This problem exists for many other problems also. Please fix this

Admin, Is there a way I can

sijuv @ 24 Feb 2010 02:15 PM

Admin,

Is there a way I can know for what particular input it is a WA?

No. FAQ

triplem @ 24 Feb 2010 02:34 PM

No. FAQ

Hi My solution is giving

shwetanka_19 @ 11 Jul 2010 10:16 PM

Hi

My solution is giving runtime error. Can I find out what type of error is it showing?

Hi My solution is giving

shwetanka_19 @ 11 Jul 2010 10:16 PM

Hi

My solution is giving runtime error. Can I find out what type of error is it showing?

Are 'A' and 'a' same in mixed

shwetanka_19 @ 11 Jul 2010 10:36 PM

Are 'A' and 'a' same in mixed case or different?

@Shwetanka: Consider them

vikeshkhanna @ 27 Nov 2010 03:55 PM

@Shwetanka: Consider them different.

@Vivek: I believe N<=10^5. My program would give TLE outside that range but it got accepted. Therefore, I am sure N<=10^5

what is

u4cse10152 @ 29 Mar 2011 05:17 PM
what is this????????????????please explain the question......!!!!!!!!!!!!!!!!!

My prog works fine on my

maverickcoder @ 22 Jul 2011 01:29 AM
My prog works fine on my manual input. How does it give wrong there??

Can the characters in the

a1_3 @ 30 Jan 2012 12:39 PM
Can the characters in the initial list be between a-z or are they strictly uppercase?

What is the output for APJQ,

a1_3 @ 30 Jan 2012 10:31 PM
What is the output for APJQ, APJRS, APJRT? Is it APJR or is it APJ?

why is it showing runtime

mdadilashraf @ 31 Mar 2012 05:43 PM
why is it showing runtime error. I am a bit new to programming and your help will be most appreciated. http://www.codechef.com/viewsolution/934141

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold

HELP

Program should read from standard input and write to standard output. After you submit a solution you can see your results by clicking on the [My Submissions] tab on the problem page. Below are the possible results:

 

  • Accepted Your program ran successfully and gave a correct answer. If there is a score for the problem, this will be displayed in parenthesis next to the checkmark.
  • Time Limit Exceeded Your program was compiled successfully, but it didn't stop before time limit. Try optimizing your approach.
  • Wrong Answer Your program compiled and ran succesfully but the output did not match the expected output.
  • Runtime Error Your code compiled and ran but encountered an error. The most common reasons are using too much memory or dividing by zero. For the specific error codes see the help section.
  • Compilation Error Your code was unable to compile. When you see this icon, click on it for more information.
  • If you are still having problems, see a sample solution here.

CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com