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 » July 2010 » Block Tower

Block Tower

Problem code: BLOCKS

  • All Submissions

All submissions for this problem are available.

Dave has several rectangular blocks with which he wishes to build a tower. He may only place a block on another if its base fits within the other's base with the edges parallel. So he could place a block with a base of 1x9 on top of a block with a base of 2x9, but not on top of a block with a base of 8x8. Help Dave make the tower as tall as possible. Blocks may be rotated by any multiple of 90 degrees about any axis. Each block may only be used once, and you must use at least 3 blocks.

Input:

Input begins with an integer T (about 500), the number of test cases. Each test case begins with an integer N (chosen uniformly between 10 and 200, inclusive), the number of blocks. N lines follow, each containing 3 integers that give the dimensions of a block. All dimensions are chosen uniformly between 1 and 100, inclusive. A blank line separates each case.

Output:

For each case, first ouput an integer P>=3, indicating the number of blocks you wish to use. Follow with P lines, each containing the dimensions of a block, with the height of the block listed first (the order of the other 2 dimensions does not matter). Output the blocks in order from the top of the tower to bottom of the tower.

Scoring

Your score for each test case is the height of your tower divided by N. Your total score is the average of your scores on the individual test cases.

Sample input:

1

10
7 2 10
8 8 8
7 1 1
2 7 9
6 8 1
6 6 5
3 2 5
10 3 9
10 10 8
4 4 1

Sample output:

5
4 1 4
1 1 7
10 2 7
2 7 9
8 10 10

Score: (4+1+10+2+8)/10 = 2.5


Author: pieguy
Date Added: 9-06-2010
Time Limit: 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, 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, TEXT, WSPC


  • Submit

Comments

  • Login or Register to post a comment.

can any one plz tell mr how

mayurmaheshwari @ 2 Jul 2010 01:44 AM

can any one plz tell mr how they chooses the blocks from the given blocks to built a building.....

i m not able to understand the question....

why not the ans is...

7

10 10 8

10 9 3

10 7 2

9 7 2

8 6 1

4 4 1

7 1 1....

avg =(10+10+10+9+8+4+7)/10=5.6

............. plz someone elaborate the question.....

@Mayur: this is the

pieguy @ 2 Jul 2010 01:55 AM

@Mayur: this is the tiebreaker problem, which means there is no single correct answer.  Any answer that conforms to the output specification and represents a valid tower will be considered correct.  Please refrain from discussing answers to specific test cases during an active contest.

Can a block with base a*b be

xeronix @ 4 Jul 2010 12:44 AM

Can a block with base a*b be placed above other one with same dimensions of base.

@Vipul: yes

pieguy @ 4 Jul 2010 06:46 AM

@Vipul: yes

is given sample output is the

v_new.c @ 7 Jul 2010 12:52 AM

is given sample output is the tower of maximum

hieght ? if it is then what is it

8 1 6

10 2 7

10 3 9

2 7 9

8 10 10

score=3.8

anyone please help

thanks

The sample output is just

triplem @ 7 Jul 2010 03:00 AM

The sample output is just that; a sample. It is not necessarily the optimal answer.

does wrong answer can be

v_new.c @ 7 Jul 2010 02:31 PM

does wrong answer can be segmentation fault?

No.

mcsharma1990 @ 7 Jul 2010 04:30 PM

No.

@atul wrong answer and

Juned123 @ 7 Jul 2010 09:42 PM

@atul

wrong answer and segmentation fault are two different things.

For segmentation fault you will be shown a runtime error icon.

does input is always >=3 or

v_new.c @ 8 Jul 2010 01:34 AM

does input is always >=3

or we have to consider the case?

sorry for previous one it is

v_new.c @ 8 Jul 2010 01:37 AM

sorry for previous one it is clear in problem.

is it ok if i give the output

bbsgbbsg @ 11 Jul 2010 12:46 AM

is it ok if i give the output immeadiately after each test case is entered rather than after all of them have been entered?

It's not only OK, but it is

triplem @ 11 Jul 2010 04:35 AM

It's not only OK, but it is what you should be doing. See the FAQ.

This was a nice problem to

shettynamit @ 12 Jul 2010 11:51 AM

This was a nice problem to solve.... I thought that I had found out an optimal solution(and still think so) , but apparently I have been wrong....considering the scores.  Any pointers as to y it is not possible to find the perfect solution?

I also think there is a

cgy4ever @ 12 Jul 2010 01:26 PM

I also think there is a perfect algorithm before.

But some details made it tough to use one block just once.

And when the height of each blocks is determined , it is easy to find a perfect algorithm.

Of course choosing one block

shettynamit @ 12 Jul 2010 03:12 PM

Of course choosing one block at most once was tricky, but I thought I had passed that hurdle by keeping some indicator(a true/false value).... Is thr nething else I mite hav missed ? my score was .992 , so i am sure it must be some small case.

Post The Tutorials for this

theeporithirumugam @ 14 Jul 2010 11:02 AM

Post The Tutorials for this month contest,,,(JULY10)

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