I woke up early today for SRM ( 7 AM ) . I solved 2 problems DIV-2 Easy and Medium.
My Solution:
n ( 2 <=n <= 8 ) is so small. So, I checked recursively all Five rotations.
4 rotations; where up and down side ( White color ) is constant. ( If we consider initial position also a rotation for easy to computation. ).
1 rotation; where up and down side is reverse.
In contest time, I had written code without checking the last rotation ( up and down side is reverse ) and got Wrong Answer for last test-case. Finally figured it by my
Room Score Board
DIV-2 Score Board
DIV-2 easy is just an implementation problem.
Problem Statement of DIV-2 easy |
|||||||||||||
You found a deck of slightly non-traditional playing cards. Each
card has a value and a suit. The value of each card is a positive
integer, and the suit is a lowercase English letter ('a'-'z'). We
will use (v, s) to denote a card with value v and suit s.
You want to know whether the deck is perfect. A perfect deck has two properties:
You are given the following data:
|
|||||||||||||
Definition |
|||||||||||||
|
|||||||||||||
Limits |
|||||||||||||
|
|||||||||||||
Constraints |
|||||||||||||
- | n will be between 1 and 50, inclusive. | ||||||||||||
- | value will contain exactly n elements. | ||||||||||||
- | Each element of value will be between 1 and 1,000,000,000, inclusive. | ||||||||||||
- | suit will be of length n exactly. | ||||||||||||
- | Suit will only contain lower-case alphabets ('a'-'z').
My Solution : I used STL map to solve the problem. |
Problem Statement of DIV-2 Medium |
|||||||||||||
You recently designed the Cube Stacking Game. This is a
single-player puzzle. All you need to play the game is a
collection of cubes, as described below.
You have n cubes. The cubes are numbered from 0 to n-1. Each face of each cube has a single color. There are n+1 colors. One of the colors is white and has number 0. The remaining colors have numbers 1 to n. Each cube has exactly two white faces, and these are always two opposite faces. Let's number the remaining faces on each cube 1, 2, 3, 4 in adjacent order. (That is, face 1 is adjacent to 2, 2 to 3, 3 to 4, and 4 to 1.) For each cube, you are given the colors of these four faces: on cube i these faces have colors c1[i], c2[i], c3[i] and c4[i], in order. Remember that these faces are never white. You want to build a single stack of cubes with cube 0 on the bottom, cube 1 on top of cube 0, and so on. (I.e., you have to use the cubes in the given order, starting with 0, and you are not allowed to skip any cube.) The cubes have to be aligned to form a single stack with four vertical sides. You may rotate the cubes arbitrarily but you must place them onto the stack in such a way that the top and bottom face of each cube will be white. On each of the four sides of the stack each color can only appear at most once. Calculate and return the maximum height of a valid stack that can be built out of the given cubes. |
|||||||||||||
Definition |
|||||||||||||
|
|||||||||||||
Limits |
|||||||||||||
|
|||||||||||||
Constraints |
|||||||||||||
- | n will be between 2 and 8, inclusive. | ||||||||||||
- | Each of c1, c2, c3, c4 will contain exactly n elements. | ||||||||||||
- | Each element of c1 will be between 1 and n, inclusive. | ||||||||||||
- | Each element of c2 will be between 1 and n, inclusive. | ||||||||||||
- | Each element of c3 will be between 1 and n, inclusive. | ||||||||||||
- | Each element of c4 will be between 1 and n, inclusive. |
My Solution:
n ( 2 <=n <= 8 ) is so small. So, I checked recursively all Five rotations.
4 rotations; where up and down side ( White color ) is constant. ( If we consider initial position also a rotation for easy to computation. ).
1 rotation; where up and down side is reverse.
In contest time, I had written code without checking the last rotation ( up and down side is reverse ) and got Wrong Answer for last test-case. Finally figured it by my
Rubik's Cube.
Room Score Board
DIV-2 Score Board
Comments
Post a Comment