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 » May 2009 (Contest III) » Best board fill

Best board fill

Problem code: CX

  • All Submissions

All submissions for this problem are available.

The following a tie breaker problem. The best solution will receive one point. All other successful answers will be scored on a curve and receive a fraction of a point based on how close they come to the best answer.

Given a large board (with holes) and set of tetris-like figures (an unlimited source, capable of generating any number of them), try to cover the board as exactly as possible.
The source is capable of generating the following pieces:

1)
###
.#.

2)
##.
.##

3)
#.#
###

4)
###
#..

5)
..#
###
#..

6)
#.#
###
.#.



You are allowed to flip and rotate pieces before placing them on the board.

Input

The first line contains two numbers - 100<=n,m<=1000 - the height and the width of the board.
The next n lines, each containing m space-separated numbers, are the board description. The symbol '0' is a square which should be filled, the symbol '1' is a square which should not be filled.

Output

First output the number of pieces used, k < 106. Then write k successive descriptions of the used pieces. Each description should be of the form: t - the number of full squares of the piece, followed by t pairs of integers denoting the coordinates of the respective squares (using 0-based offsets, with the top-left of input written as (0,0) ).

Example

Input:
3 3
0 0 0
0 1 0
0 0 0


Output:
2
4
0 0
0 1
1 1
0 2
4
0 2
1 2
2 2
2 1

Scoring

For each square you will receive a penalty, calculated in the following way:
Let a be the number a square should be covered by (either 0 or 1), and let b be the actual number of times the square has been covered by a # piece (pieces may overlap). If a > b (the square should have been covered, but was not), the penalty is 3. If b > a (the square should not have be covered and was covered, or should have been covered, but was covered more than once), the penalty is b-a.
The total penalty is the sum of individual penalties, taken over all squares.

In the example the penalty is 3+3+1+1 = 8.

Tests

All tests have been randomly generated, with 1 covering less than 40% of the total number of squares.


Date: 2009-04-15
Time limit: 1s
Source limit: 50000
Languages: C C99 strict C++ 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 HASK CAML CLPS PRLG WSPC BF ICK TEXT


  • Submit

Comments

  • Login or Register to post a comment.

anton_lunyov @ 4 May 2009 10:40 AM

I can't understand are total points equal sum or maximum of penalties for all tests?

prunthaban @ 5 May 2009 05:32 AM

@Anton It should be sum of penalties from what I know.

prunthaban @ 6 May 2009 05:35 PM

Oh Well. It does not look like the penalty is a simply sum. In that case we would not get decimals.

jvimal @ 7 May 2009 03:04 AM

@Prunthaban: It could be the average, right?

admin 2 @ 7 May 2009 07:31 PM

Scoring section updated with the following clarification: The program will be run several times for different data sets and the overall score will be the mean of scores received.

Can anyone please explain the

devanshukashyap @ 14 Oct 2011 10:40 PM
Can anyone please explain the solution to this problem.. The successful submissions are inexplicabele. plzz

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