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
    • February CookOff
    • February Long Contest
    • January CookOff
  • DISCUSS
    • Wiki
    • Forums
    • Blog
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
    • Event Calendar
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Ranks
    • Tutorials
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » December 2009 (Contest XI) » Park tour

Park tour

Problem code: KX

  • All Submissions

All submissions for this problem are available.

The Chef is strolling in a large nxn square park composed of small unit squares. Some squares are occupied by trees, and the rest is free to walk through them. The Chef wants to lose weight and hence wants to walk a lot. Your job is to create a visiting route which should be as long as possible. The route should be a closed curve with no self-intersections, and is defined by describing the sequence of squares through which it passes. From one square, the route can only proceed to a square which shares a common edge with it. The route enters and leaves each square in the central points of two of its edges. If those two points lie on opposing edges of the square (N - S or E - W), the fragment of the route within the square is a straight line segment of length l=1. Otherwise, if the two points lie on adjacent edges, the route within the square is an arc of the circle (1/4th of the full circle of radius 1/2, centered at the common corner of the edges) and its length is l=pi/4.

Input

In the first line of input there is an integer n (100 n 800), denoting the size of park. The following n lines of n characters each describe the park: the character '*' represents a square with a tree, and the character '.' means that the square is empty.

Output

First, an integer k (0<k), corresponding to the number of lines of the subsequent description of the output. The following k pairs of numbers should describe the squares of the route: i1,j1 ... ik,jk, where i is the row number (counting from 0) and y is the column number (counting from 0) of a square.

Correctness of the output

For each i<k, squares i and i+1 of the route should share a common edge, and moreover the first and the k-th squares should also share a common edge. The route may not make a U-turn at any square, and may not lead through any squares with trees. The route should not self-intersect or touch itself. The route is not allowed to lead outside the park. Note that it is possible for the route to be twice in the same square (i.e. once enter from N exiting due E, later enter from S exiting due W).

Example

Input:
3
..*
...
*..

Output:
8
0 0
0 1
1 1
1 2
2 2
2 1
1 1
1 0
Score:
0.897598

Test distribution

n will be chosen uniformly from the range [100,800] range. The number of trees will be chosen uniformly from the range [n2*alfa,n2*2*alfa), where alfa = 0.1 for 1/3 of the testcases, alfa = 0.02 for 1/3 of the testcases, and alfa = 0.004 for 1/3 of the testcases. Positions of trees are chosen uniformly at random.

Scoring

The score is given as l / f, where l is the total length of the route and f is the total number of squares without trees.


Date: 0000-00-00
Time limit: 10

s
Source limit: 50000
Languages: C C99 strict C++ 4.0.0-8 C++ 4.3.2 PAS gpc PAS fpc JAVA NICE JAR C# C#2 NEM ST ASM D FORT ADA BASH PERL PYTH RUBY LUA ICON PIKE PHP SCM guile SCM qobi LISP sbcl LISP clisp SCALA HASK ERL CAML CLPS PRLG WSPC BF ICK TEXT JS


  • Submit

Comments

  • Login or Register to post a comment.

Is judge data not uploaded

pr0ton @ 1 Dec 2009 10:28 PM

Is judge data not uploaded yet? I get Internal Error.

This is fixed.

admin @ 1 Dec 2009 11:09 PM

This is fixed.

" i1,j1 ... ik,jk, where i is

pieguy @ 2 Dec 2009 11:56 AM

" i1,j1 ... ik,jk, where i is the row number (counting from 0) and y is the column number (counting from 0)"

should be j, not y, ya?

Yes that should be 'j'.

admin @ 2 Dec 2009 04:34 PM

Yes that should be 'j'.

What compiler options do you

akuegel @ 4 Dec 2009 10:20 PM

What compiler options do you use for the C++ compiler? I am especially interested in knowing if you use -O2 or something similar. Also, how fast is the server?

Is scoring for this problem

rem @ 4 Dec 2009 11:15 PM

Is scoring for this problem correct? I currently have 6 points in the ranklist, but my solution is very trivial. Shouldn't I have 5+eps points with such solution?

Points are not updating when

pieguy @ 5 Dec 2009 10:09 AM

Points are not updating when a new high score is submitted.  Please fix.

hi

prateek dhuper @ 5 Dec 2009 11:59 AM

hi

hi

prateek dhuper @ 5 Dec 2009 11:59 AM

hi

hi

prateek dhuper @ 5 Dec 2009 11:59 AM

hi

My score of 3.2e-5 seems

tomek @ 6 Dec 2009 12:30 PM

My score of 3.2e-5 seems incorrect. Please verify. Is the total score the sum of individual test case scores?

I think (at least based on

triplem @ 6 Dec 2009 12:47 PM

I think (at least based on the other contests) it is an average, though a current top score of 1.347 seems strangely high if that is the case. So I wouldn't mind this being clarified as well.

I see, if it's the average

tomek @ 6 Dec 2009 04:35 PM

I see, if it's the average then the scores make sense.

Another strange thing.

thocevar @ 6 Dec 2009 04:37 PM

Another strange thing. Rankings show my score as 0.867, which is correct if the top score is actually 1.347. But the list of submissions shows 0.88 although this was the latest submission - nobody submitted after me.

Your sample test case doesnt

innocentboy @ 8 Dec 2009 02:07 AM

Your sample test case doesnt follow your test data distribution constraints.

n*n = 9 here so ideally we shouldnt have had 2 trees ;) [ max 1.8 ]

Ajay: it doesn't say that the

tomek @ 8 Dec 2009 01:46 PM

Ajay: it doesn't say that the example has been chosen randomly using the same distribution as the actual tests. It obviously hasn't since n < 100.

 

Admins: the scores in the scoreboard are still wrong.

Oh yes, I missed that

innocentboy @ 8 Dec 2009 04:56 PM

Oh yes, I missed that completely. Thanks.

I think we've been more than

thocevar @ 9 Dec 2009 07:28 PM

I think we've been more than just patient so far. Is this discussion intentionally ignored by admins? Any kind of response would be appreciated. Why do relative scores in submissions list differ from those displayed on the rankings? The latter seem to be correct.

This will be fixed soon. As

admin @ 9 Dec 2009 07:37 PM

This will be fixed soon. As of now, the value in the ranklist is correct.

When will the solutions be

rajatag12 @ 11 Dec 2009 04:12 PM

When will the solutions be made public, if they will be, at all ?

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 computer programming. At CodeChef we work hard to revive the geek in you by hosting programming contests on a monthly basis. We also aim to have training sessions and events related to online programming for programmers around the world. Apart from providing a platform for programming competitions, CodeChef also has various 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 judge accepts solutions in over 35+ programming languages. Online programming was 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 competitions 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 programming contests and the shorter format Cook-off programming contests. Put yourself up for recognition and win great prizes. Prizes worth up to Rs.20,000 and $700 are up for grabs every month along with lots more CodeChef goodies.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be part of CodeChefs Forums and interact with all our programmers love helping out other programmers and share their ideas.

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. Be a part of the CodeChef community through CodeChef meetups and techtalks. You can also host a programming contest for your institute on CodeChef and be a guest author on our blog.

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