915 - Stack of Cylinders

All about problems in Volume 9. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
Abednego
A great helper
Posts: 281
Joined: Tue Sep 10, 2002 5:14 am
Location: Mountain View, CA, USA
Contact:

915 - Stack of Cylinders

Post by Abednego »

The problem description is ambiguous. Why is the path not (2, 3, 6, 7)? It seems that if cylinder 7 were big enough, it would be part of the path. What is the precise definition of the "continous path" and the "path tail"?
If only I had as much free time as I did in college...
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

See the picture in the problem. Imagine that some circles are packed in a rectangle. Suppose you need length 'x' to pack all the circles. To be more precise suppose you have to place all the circles between two vertical lines. 'x' is the minimum required length between the vertical lines. Now the circles that cant be removed (otherwise the value of 'x' will decrease) are the elemets of the continuous path. Path Head means the first circle that should be taken, and Path Trail means the last circle that should be taken.

2, 3, 6, 7 is not the answer because if you remove 7, it has no effect to 'x'. But if you remove 2, 3 or 6; 'x' will decrease.

Hope you understand.
Ami ekhono shopno dekhi...
HomePage
yiuyuho
A great helper
Posts: 325
Joined: Thu Feb 21, 2002 2:00 am
Location: United States
Contact:

Post by yiuyuho »

It is ensured that each cylinder can touch no more than one cylinder at its left and no more than one cylinder at its right.

What cylinders is it refering to? 3 is touching 4 and 6 on the right, right? :-)
Jan
Guru
Posts: 1334
Joined: Wed Jun 22, 2005 10:58 pm
Location: Dhaka, Bangladesh
Contact:

Post by Jan »

yiuyuho wrote:It is ensured that each cylinder can touch no more than one cylinder at its left and no more than one cylinder at its right.

What cylinders is it refering to? 3 is touching 4 and 6 on the right, right? :-)
Right!

May be they are talking about the cylinders which make the path.
Ami ekhono shopno dekhi...
HomePage
sinclair
New poster
Posts: 1
Joined: Mon Jul 27, 2009 11:55 am

Re: 915 - Stack of Cylinders

Post by sinclair »

Help me please.....
I don't know what i have to use to solve this kind of problem.
any help please?????
Thank u.
metaphysis
Experienced poster
Posts: 139
Joined: Wed May 18, 2011 3:04 pm

Re: 915 - Stack of Cylinders

Post by metaphysis »

Test data generator.

Code: Select all

#include <iostream>
#include <cstdlib>
#include <ctime>

using namespace std;

const int MAX_CASES = 100;

int main(int argc, char *argv[])
{
    srand(time(NULL));
    
    for (int c = 1; c <= MAX_CASES; c++)
    {
        int circles = rand() % 90 + 10;
        
        cout << circles << '\n';
        
        for (int i = 1; i <= circles; i++)
        {
            int radius = rand() % 1000 + 3;
            cout << radius << '\n';
        }
    }
    
    return 0;
}
Post Reply

Return to “Volume 9 (900-999)”