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 » Dementia 2012 - IIT Mandi » Protecting Sheep

Protecting Sheep

Problem code: PRTCTSHP

  • All Submissions

All submissions for this problem are available.

Useless Fencing Inc. has recently scored a contract to create a fence around a bunch of sheep in light of recent wolf attacks. As implied by their name, Useless Fencing tries to use as little fencing material as possible.

In order to determine the location of each of the sheep, Useless Fencers has deployed a system consisting of laser range-finders. This has given them the location of each of the sheep, however because of errors inherent in the system, they only know that each of the sheep is inside a square of side 2 units. (Note that the orientation of all of these squares is identical, and the coordinate system has been selected so that each of the sides are parallel to one of the axes.)

The sheep are rather lazy (they never move), but none of them should be left outside the fence. Your task is to determine the minimum possible length of the fence.

Input Format

The first line contains a single integer p representing the number of sheep. This line is followed by p lines each containing two non-negative floats which correspond to the cartesian coordinates of each of the sheep.

Output Format

You should output a single line containing the length of the fence required. Your answer will be a floating point number, the judge will ignore FP rounding up to 10-6.

Example

Input:


5
0.0 0.0
0.0 1.0
1.0 0.0
1.0 1.0
0.5 0.5

Output:


12.0

Author: singh_sume
Date Added: 12-01-2012
Time Limit: 9 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


  • Submit

Comments

  • Login or Register to post a comment.

The fence should be a

crazysaikat @ 21 Jan 2012 06:58 PM
The fence should be a rectangle with side parallel to axis??

crazysaikat: No, Useless

vikhyat @ 21 Jan 2012 07:04 PM
crazysaikat: No, Useless Fencing Inc. is willing to allow a fence of any shape if it means saving money on fencing material. :)

What is maximal number of

maksim_banin @ 21 Jan 2012 07:15 PM
What is maximal number of sheeps?

I don't think the test data

dj3500 @ 21 Jan 2012 07:18 PM
I don't think the test data is correct. Please recheck it.

@vikhyat : Till how many

crazysaikat @ 21 Jan 2012 07:20 PM
@vikhyat : Till how many digits after the decimal point we have to print??

dj3500: i'm looking into it,

vikhyat @ 21 Jan 2012 07:28 PM
dj3500: i'm looking into it, sorry! crazysaikat: atleast 6 for now.

Can u please explain how the

soumyaukil @ 21 Jan 2012 07:29 PM
Can u please explain how the o/p is turning out to be 12?

given cordinates are sheep's

loonydmad @ 21 Jan 2012 07:58 PM
given cordinates are sheep's position or square position??

loonydmad: the sheep's; it

vikhyat @ 21 Jan 2012 08:15 PM
loonydmad: the sheep's; it lies at the center of square.

dj3500 and everyone else: the

vikhyat @ 21 Jan 2012 08:16 PM
dj3500 and everyone else: the error has been fixed, very sorry about that.

soumyaukil: try plotting the

vikhyat @ 21 Jan 2012 08:37 PM
soumyaukil: try plotting the points on graph paper and draw the squares around them. it will become quite clear. :)

limits on p (number of

aseem_pandey @ 21 Jan 2012 08:40 PM
limits on p (number of sheeps) ????

"each of the sheep is inside

aseem_pandey @ 21 Jan 2012 08:49 PM
"each of the sheep is inside a square of side 2 units" does this mean all the p sheeps will be inside one square of side of 2 units or that for each of the sheep, it's real position is within a square of side 2 units irrespective of other sheeps ?

can you give some more test

deepak_nitk @ 21 Jan 2012 08:55 PM
can you give some more test cases

aseem_pandey: each sheep is

vikhyat @ 21 Jan 2012 08:59 PM
aseem_pandey: each sheep is within a square of side 2, independent of the other sheep (your second interpretation). the number of sheep is not that large, it will be less than or equal to 999.

deepak_nitk:

vikhyat @ 21 Jan 2012 09:12 PM
deepak_nitk: http://pastie.org/3225304

u guys should have clearly

mprateek @ 21 Jan 2012 09:57 PM
u guys should have clearly mentioned how many decimal places we need to print. I tried printing to 1, 6 but it didn't worked. Then I printed it to 8 decimal places and it was correct. How can one guess such things !!!

mprateek: It _is_ mentioned

vikhyat @ 21 Jan 2012 09:59 PM
mprateek: It _is_ mentioned in the problem statement: "Your answer will be a floating point number, the judge will ignore FP rounding up to 10^-6."

what will output for : (0.0,

mkagenius @ 21 Jan 2012 11:22 PM
what will output for : (0.0, 0.0) and (100.0, 0.0) , is it 16.0 ?

mkagenius: no, 208.0

vikhyat @ 21 Jan 2012 11:27 PM
mkagenius: no, 208.0

shud the fence be such that

dr_go_fast @ 21 Jan 2012 11:35 PM
shud the fence be such that it can be drawn without picking the pen??

dr_go_fast: Yes, it will be

vikhyat @ 21 Jan 2012 11:39 PM
dr_go_fast: Yes, it will be like that. Otherwise wolves will be able to get in. :D

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