P24941 [AtCoder] [ARC021A] DEAD END
入门
题目描述

Problem Description

You are strongly recommended by your friend Takahashi to play a certain game.

This game is played using a $4 \times 4$ grid divided into 16 cells, with tiles placed on them, each bearing a number. In one operation, you can specify one of the four directions (up, down, left, right), and the tiles on the cells will slide in that direction. When two tiles with the same number collide, they are removed from the grid, and a new tile with twice the number is placed in one of their positions.

The following figure shows an example of the state of the board and the state after performing one operation to the right.

The game is over when no tiles can slide in any direction and no tiles with the same number can collide. The goal is to create the largest number on a tile before the game ends.

This game seems very interesting, but you find it difficult to determine whether it's game over when the grid is full of tiles, perhaps because you are not yet familiar with it. Therefore, you decide to write a program that determines whether the game is over given the information of the tiles on the grid.

Input Format

The input is given from the standard input in the following format:

$ A_{1,1} $ $ A_{1,2} $ $ A_{1,3} $ $ A_{1,4} $ $ A_{2,1} $ $ A_{2,2} $ $ A_{2,3} $ $ A_{2,4} $ $ A_{3,1} $ $ A_{3,2} $ $ A_{3,3} $ $ A_{3,4} $ $ A_{4,1} $ $ A_{4,2} $ $ A_{4,3} $ $ A_{4,4} $

  • The information of the tiles is written over 4 lines. $ A_{r,c} $ $(2 \leq A_{r,c} \leq 2048)$ represents the number written on the tile in the cell counted from the top as the $ r $-th row and from the left as the $ c $-th column.
  • All $ A_{r,c} $ are powers of 2. That is, $ A_{r,c} $ is one of $ 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048 $.

Output Format

Output GAMEOVER if the given state of the grid is a game over, or CONTINUE if there are still possible operations.

Include a newline at the end of the output.

Sample Input and Output

Sample Input #1

2 8 2 2
32 2 8 8
4 64 2 128
2 8 4 2

Sample Output #1

CONTINUE

Sample Input #2

2 4 16 4
8 32 128 8
2 64 16 2
32 4 32 4

Sample Output #2

GAMEOVER

Sample Input #3

2 4 2 4
4 2 4 2
2 4 2 4
4 2 4 2

Sample Output #3

GAMEOVER

Notes/Hints

Sample Explanation 1

Tiles cannot be moved up or down, but they can be moved left or right to collide tiles with the number 2 or 8.

Sample Explanation 2

No matter which direction you try to move, you cannot collide tiles with the same number.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
2 8 2 2 32 2 8 8 4 64 2 128 2 8 4 2
样例输出
CONTINUE