Page 1 of 1

### 915 - Stack of Cylinders

Posted: Thu Nov 02, 2006 12:40 am
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"?

Posted: Thu Nov 02, 2006 1:09 am
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.

Posted: Fri Jun 29, 2007 7:48 am
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? Posted: Fri Jun 29, 2007 10:09 am
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.

### Re: 915 - Stack of Cylinders

Posted: Mon Jul 27, 2009 11:57 am
I don't know what i have to use to solve this kind of problem.
Thank u.

### Re: 915 - Stack of Cylinders

Posted: Sun Feb 11, 2018 4:04 am
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;