### coloration problem

Hi this follow link is the one of the ACM competition problem PDF.

https://icpcarchive.ecs.baylor.edu/external/20/2029.pdf

I'm not sure how to represent the triangle form in c++

i was think about the array form or linked list but i need some help to start this new concept of problem.
give me a hint for this problem
Last edited on
Just stick it in some vectors?

Make a class to store these vectors?
Hi

can u explain little bit more?

or give me some example for 2 lengh triangle?
Last edited on
Well, storing the data should be easy.

Let's say we have a class to store the colour (or whatever data you need) called `Colour`.

Then to store the triangle we could use (for instance) a `std::vector<std::vector<Colour>>`.

e.g:
 ``12345678`` ``````std::vector> triangle; // . . . n = 2; // . . . triangle.resize(n); for (int i = 0; i < n; ++i) { triangle[i].resize(i * 2 + 1); }``````

Or something like that.
if u think about 3 length triangle

each triangle's adjacent is tangled each other

Im not sure how this going to work with simple array(vector)
You have to find a way of calculating the desired indices when you need them. If that's a pain to do, wrap it in a class.
You should concentrate less on creating a class to represent the triangles and focus more and the keyword in the question; which is that this is a combination/permutations problem http://en.wikipedia.org/wiki/Combination

What do you know about the number of triangles in an equilateral triangle of side length n?

In what case would having k paints not be enough to satisfy the case:
 In such a triangle, the contiguous stones are required not to be painted with the same color.

How many non-contiguous triangles are there in a triangle of m triangles?

So on...
Topic archived. No new replies allowed.