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 » Compete » DreamSpark 2010 » References

References

Problem code: DPC106

  • All Submissions

Editors of an electronic magazine make draft versions of the documents in the form of text files. However, publications should meet some requirements, in particular, concerning the rules of reference use. Unfortunately, lots of the draft articles violate some rules. It is desirable to develop a computer program that will make a publication satisfy all the rules from a draft version.

Let's call a "paragraph" a set of lines in the article going one after another, so that paragraphs are separated by at least one empty line (an "empty line" is a line that containing no characters different from spaces). Any paragraph can contain an arbitrary number of references. A reference is a positive integer not greater than 999 enclosed in square brackets (for example: [23]). There will be no spaces between the brackets and the number. The square brackets are not used in any other context but reference.

There can be two types of paragraph - "regular" and "reference description". Reference description differs from the regular paragraph because it begins with the reference it describes, for example:

[23] It is the description ...

The opening square bracket will be at the first position of the first line of the "reference description" paragraph (i.e. there will be no spaces before it). No reference description paragraph will contain references inside itself.

Each reference will have exactly one corresponding description and each description will have at least one reference to it.

To convert a draft version to a publication you have to use the following rules.

  • References should be renumbered by the successive integer numbers starting from one in the order of their first appearance in the regular paragraphs of the source draft version of the document.
  • Reference descriptions should be placed at the end of the article ordered by their number.
  • The order of "regular" paragraphs in the document should be preserved.
  • Your program should not make any other changes to the paragraphs.

Input

The input file will be a text file containing a draft article your program should process. All lines will be no more than 80 characters long. Any reference description will contain no more than 3 lines. The input file will contain up to 40000 lines.

Output

The output file contains the result of processing. All paragraphs should be separated by one "true" empty line (i.e. a line that contains no characters at all). There should be no empty lines before the first paragraph.

Sample input

[5] Brownell, D, "Dynamic Reverse Address Resolution Protocol
    (DRARP)", Work in Progress.

The Reverse Address Resolution Protocol (RARP) [10] (through the
extensions defined in the Dynamic RARP (DRARP) [5]) explicitly
addresses the problem of network address discovery, and includes an
automatic IP address assignment mechanism.

[10] Finlayson, R., Mann, T., Mogul, J., and M. Theimer, "A Reverse
        Address Resolution Protocol", RFC 903, Stanford, June 1984.

[16] Postel, J., "Internet Control Message Protocol", STD 5, RFC 792,
        USC/Information Sciences Institute, September 1981.


The Trivial File Transfer Protocol (TFTP) [20] provides for transport
of a boot image from a boot server.  The Internet Control Message
Protocol (ICMP) [16] provides for informing hosts of additional
routers
via "ICMP redirect" messages.

[20] Sollins, K., "The TFTP Protocol (Revision 2)",  RFC 783, NIC,
     June 1981.

Works [10], [16] and [20] can be obtained via Internet.

Output for the sample input

The Reverse Address Resolution Protocol (RARP) [1] (through the
extensions defined in the Dynamic RARP (DRARP) [2]) explicitly
addresses the problem of network address discovery, and includes an
automatic IP address assignment mechanism.

The Trivial File Transfer Protocol (TFTP) [3] provides for transport
of a boot image from a boot server.  The Internet Control Message
Protocol (ICMP) [4] provides for informing hosts of additional routers
via "ICMP redirect" messages.

Works [1], [4] and [3] can be obtained via Internet.

[1] Finlayson, R., Mann, T., Mogul, J., and M. Theimer, "A Reverse
        Address Resolution Protocol", RFC 903, Stanford, June 1984.

[2] Brownell, D, "Dynamic Reverse Address Resolution Protocol
    (DRARP)", Work in Progress.

[3] Sollins, K., "The TFTP Protocol (Revision 2)",  RFC 783, NIC,
     June 1981.

[4] Postel, J., "Internet Control Message Protocol", STD 5, RFC 792,
        USC/Information Sciences Institute, September 1981.

Author: rushikesh30
Date Added: 25-02-2010
Time Limit: 30 sec
Source Limit: 50000 Bytes
Languages: C, C99 strict, CLOJ, CPP 4.0.0-8, CPP 4.3.2, CS2, F#, GO, JAVA, PERL6, PYTH 3.1.2, TEXT


  • Submit

Comments

  • Login or Register to post a comment.

We have recieved Correct

MSP_bitmesra @ 28 Feb 2010 11:40 AM

We have recieved Correct Submissions for this Problem Which means that the Question and Input/Output is Valid

Special Thanks to Rushikesh

MSP_bitmesra @ 28 Feb 2010 11:52 AM

Special Thanks to

Rushikesh Deshpande (ISMU Dhanbad);  Shahzor Khan(BIT Mesra); Kunal Jain(IIIT Hyderabad); Gourab Mitra(MSP BIT Mesra); Subhradip Saha(MSTC BIT Mesra)

how "additional routers" came

long_road @ 28 Feb 2010 07:32 PM

how "additional routers" came in the same line in previous output??

admin please answer !!!!!i

singh.ritesh79 @ 28 Feb 2010 08:24 PM

admin please answer !!!!!
i think "via "ICMP redirect" messages." should be printed in newline.

and routers in another new

singh.ritesh79 @ 28 Feb 2010 08:26 PM

and routers in another new line but that is not the case.

@ALL Please mail your

MSP_bitmesra @ 28 Feb 2010 09:20 PM

@ALL

Please mail your CodeChef ID, your name, your Institutions Name, Your Address(Where you want Posters, Certis, Goodies to be delivered, (No. of deliveries will depend on our budget)) to dreamsparkyatra@gmail.com For Updates follow http://twitter.com/dreamsparkyatra .

Happy Holi and Happy Coding!

@Ritesh Sorry for Late Reply.

MSP_bitmesra @ 28 Feb 2010 09:23 PM

@Ritesh

Sorry for Late Reply. This Question has recieved correct enteries, so we can't say anything about the question.

I don't think this is the

singh.ritesh79 @ 28 Feb 2010 09:57 PM

I don't think this is the right answer of my question.

If this is your logic,you must be thinking same about Problem NUMBERS which is not correct.

@ALL "All paragraphs should

singh.ritesh79 @ 28 Feb 2010 10:21 PM

@ALL

"All paragraphs should be separated by one "true" empty line"

This is not true for descriptions(and it's something i was trying to know from organizers).

thanks


@All Check out the DreamSpark

MSP_bitmesra @ 28 Feb 2010 11:44 PM

@All

Check out the DreamSpark Professional Programming Contest #2 on 13th March 18:00 hours IST. We will send Posters to Participants by Post to promote the Contest Series. We'll also Send Participation E-Certis.

@All Check out the

MSP_bitmesra @ 28 Feb 2010 11:45 PM

@All

Check out the DreamSpark Professional Programming Contest #2 on 13th March 18:00 hours IST. We will send Posters to Participants by Post to promote the Contest Series. We'll also try to Send Participation E-Certis.

@vishal gupta i tried lot to

vish @ 1 Mar 2010 12:13 AM

@vishal gupta

i tried lot to get AC for "References DPC106" but every time got wrong ans. Can i have ur solution at vikas.cse.nitt@gmail.com

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
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