Итоговый счет: s , с оставшимися b шарами



Оставляйте пустую строку между выводами каждой игры. Используйте формы множественного числа "шары" и "баллы", даже если соответствующее значение равно 1.

 

Пример ввода

3

RGGBBGGRBRRGGBG

RBGRBGRBGRBGRBG

RRRRGBBBRGGRBBB

GGRGBGGBRRGGGBG

GBGGRRRRRBGGRRR

BBBBBBBBBBBBBBB

BBBBBBBBBBBBBBB

RRRRRRRRRRRRRRR

RRRRRRGGGGRRRRR

GGGGGGGGGGGGGGG

RRRRRRRRRRRRRRR

RRRRRRRRRRRRRRR

GGGGGGGGGGGGGGG

GGGGGGGGGGGGGGG

BBBBBBBBBBBBBBB

BBBBBBBBBBBBBBB

RRRRRRRRRRRRRRR

RRRRRRRRRRRRRRR

GGGGGGGGGGGGGGG

GGGGGGGGGGGGGGG

RBGRBGRBGRBGRBG

BGRBGRBGRBGRBGR

GRBGRBGRBGRBGRB

RBGRBGRBGRBGRBG

BGRBGRBGRBGRBGR

GRBGRBGRBGRBGRB

RBGRBGRBGRBGRBG

BGRBGRBGRBGRBGR

GRBGRBGRBGRBGRB

RBGRBGRBGRBGRBG

 

Пример вывода

Игра 1:

Шаг 1 на (4,1): удалено 32 шаров цвета B, получено 900 баллов.

Шаг 2 на (2,1): удалено 39 шаров цвета R, получено 1369 баллов.

Шаг 3 на (1,1): удалено 37 шаров цвета G, получено 1225 баллов.

Шаг 4 на (3,4): удалено 11 шаров цвета B, получено 81 баллов.

Шаг 5 на (1,1): удалено 8 шаров цвета R, получено 36 баллов.

Шаг 6 на (2,1): удалено 6 шаров цвета G, получено 16 баллов.

Шаг 7 на (1,6): удалено 6 шаров цвета B, получено 16 баллов.

Шаг 8 на (1,2): удалено 5 шаров цвета R, получено 9 баллов.

Шаг 9 на (1,2): удалено 5 шаров цвета G, получено 9 баллов.

Итоговый счет: 3661, с оставшимися 1 мячами.

 

 

Игра 2:

Шаг 1 на (1,1): удалено 30 шаров цвета G, получено 784 баллов.

Шаг 2 на (1,1): удалено 30 шаров цвета R, получено 784 баллов.

Шаг 3 на (1,1): удалено 30 шаров цвета B, получено 784 баллов.

Шаг 4 на (1,1): удалено 30 шаров цвета G, получено 784 баллов.

Шаг 5 на (1,1): удалено 30 шаров цвета R, получено 784 баллов.

Итоговый счет: 4920, с оставшимися 0 мячами.

 

Игра 3:

Итоговый счет: 0 с оставшимися 150 мячами.

 

Задача 4. Поиск сокровищ

Археологи из Музея древностей и редкостей отправились в Египет, чтобы осмотреть великую пирамиду Хеопса. Используя самые современные технологии, они смогли определить, что нижний этаж пирамиды состоит из серии прямых стен, которые пересекаются, образуя многочисленные закрытые камеры. В настоящее время не существует дверей, позволяющих попасть в любую из этих камер. Эта современная технология также точно определила местоположение сокровищницы. Эти преданные делу (и жадные) археологи хотят взорвать двери в стенах, чтобы попасть в сокровищницу. Однако, чтобы свести к минимуму ущерб произведениям искусства в промежуточных камерах (и остаться под их правительственным грантом на динамит), они хотят взорвать минимальное количество дверей. В целях структурной целостности двери должны быть взорваны только в середине стены входящего помещения.

Вы должны написать программу, которая определяет это минимальное количество дверей. Пример приведен ниже:

Ввод

Входные данные будут состоять из одного случая. 1-я строка будет целым числом n (0 <= n <= 30), определяющим количество внутренних стен, за которым следуют n строк, содержащих целые конечные точки каждой стены x1 y1 x2 y2. 4 ограждающие стены пирамиды и имеют фиксированные конечные точки на (0, 0), (0, 100), (100, 0), (100, 100) и не входят в список стен. Внутренние стены всегда простираются от одной внешней стены до другой внешней стены и расположены таким образом, что в любой точке пересекаются не более двух стен. Вы можете предположить, что никакие две данные стены не совпадают. После перечисления внутренних стен будет одна последняя строка, содержащая координаты с плавающей точкой сокровища в сокровищнице (гарантированно не лежащего на стене).

Вывод

Выведите одну строку с указанием минимального количества дверей, которые необходимо создать, в формате, показанном ниже.

Пример ввода

72

0 0 37 100

40 0 76 100

85 0 0 75

100 90 0 90

0 71 100 61

0 14 100 38

100 47 47 100

54.5 55.4

Пример вывода

Количество дверей = 2

 

Задача 5. Цифровая лаборатория

Предположим, что вы работаете в Лаборатории цифровой обработки. Вас просят написать программу с входной двоичной матрицей A, которая содержит шаблон для поиска по другой двоичной матрице B. Входной файл включает в себя размер и элементы как для A, так и для B. Процесс распознавания состоит в сканировании ряд за рядом (горизонтальное сканирование) матрицы B, когда шаблон расположен на B, вы должны отметить этот шаблон. Чтобы отметить расположенный паттерн, измените 1 на 2 и 0 на * в B. Выходным файлом вашей программы будет матрица B с отмеченными расположенными паттернами.

Ввод

Первая строка содержит размер, последующих строк матрицы A по строкам, следующая строка содержит размер B и последующих строках записаны строки матрицы B по строкам.

Вывод

Результатом является матрица B с отмеченными расположенными паттернами.

ФАЙЛ ВВОДА

2 2

1 0

1 1

5 5

1 1 0 0 0

0 1 1 0 0

1 0 0 1 0

1 1 1 1 0

0 0 1 1 1

 

Примечание: Входной файл содержит размер матрицы А, матрицу А, размер матрицы В и матрицу В.

ВЫХОДНОЙ ФАЙЛ

1 2 * 0 0

0 2 2 0 0

2 * 0 1 0

2 2 1 2 *

0 0 1 2 2

ВХОДНОЙ ФАЙЛ

1 1

15

5

1 1 0 0 0

0 1 1 0 0

1 0 0 1 0

1 1

1 1 0

0 0 1 1 1

ВЫХОДНОЙ ФАЙЛ

2 2 0 0 0

0 2 2 0 0

2 0 0 2 0

2 2 2 2 0

0 0 2 2 2

ВХОДНОЙ ФАЙЛ

1 1

05

5

1 1 0 0 0

0 1 1 0 0

1 0 0 1 0

1 1 1 1 0

0 0 1 1 1

 

ВЫХОДНОЙ ФАЙЛ

1 1 * * *

* 1 1 * *

1 * * 1 *

1 1 1 1 *

* * 1 1 1

ВХОДНОЙ ФАЙЛ

2 6

1 0 0 1 0 1

1 1 1 0 1 0

5 5

1 1 0 0 0

0 1 1 0 0

1 0 0 1 0

1 1 1 1 0

0 0 1 1 1

ВЫХОДНОЙ ФАЙЛ

1 1 0 0 0

0 1 1 0 0

1 0 0 1 0

1 1 1 1 0

0 0 1 1 1


 

Appendix 5

To the Regulation on the Competitive Selection for Huawei Company’s scholarship to

students of Tomsk State University

 

Additional Task

Completion of this task is optional. Contestant independently decides whether to provide the solution or not.

You have to choose ONE task from the following and provide your solution on the separate sheet of paper. The correct solution gives you 10 points; incorrect - 0 points.

Tasks

Task 1.Implement a parallel program and a test using C programming language and different technologies

· OpenMP

· MPI

· MPI+OpenMP

to solve one task from the list as quickly as possible:

1. Two real matrices A and B are given. Calculate the matrix C=A×B.

2. Find a solution to the system of equations A×X=Y.

3. Real matrix A and a matrix Y are given. Real triangular matrix A and a matrix Y are given. Find a solution to the system of equations A×X=Y

4. A real or complex vector x is given, find the first in order maximal modulo element of the vector.

5. Real or complex vectors x and y are given, calculate their scalar product.

6. A real matrix A and a vector x are given. Find their product.

7. A real matrix A is given, you need to transpose it.

Provide the program and the test for it in the form of source code. Provide a brief description of how they are used, the approaches applied to acceleration, and the motivation for choosing these approaches to acceleration. Solving more than one problem will be an advantage.

 

Task 2. Package Manager

A list of java packages is given. Each package has a list of dependencies. For example, the hadoop-yarn package has dependencies [hadoop-core, hadoop-dfs].

You need to write a program that is able to perform all of the following tasks.

1) Accepts a file with the required dependencies as input, in the format:

hadoop-yarn -> [hadoop-core, hadoop-dfs]

hadoop-hdfs ->

[apache-commons]

hadoop-core -> [apache-commons]

apache-commons ->

[]

flink-table-api -> [flink-core, apache-calcite, junit]

flink-core

-> [apache-commons, joda-time, lombok]

lombok -> []

joda-time ->

[]

apache-calcite -> [lombok]

flink-connectors -> [flink-core,

hbase, hadoop-yarn]

hbase -> [apache-commons, joda-time]

 

2) Accepts as input a file with the package to build and the actual list of dependencies, in the format:

flink-table-api -> [flink-core, apache-commons,

joda-time, hbase, apache-calcite]

 

3) Missing dependencies/ Implements the getMissing Dependencies() method, in this case it should return Missing dependencies:

flink-table-api -> junit

flink-table-api -> flink-core

-> lombok

 

4) Excess dependencies/ Implements the getExcessDependencies() method, in this case it should return Excess dependencies:

- hbase

5) Implements a method for displaying a branch with a dependency (getDependencyTree("apache-commons")), in this case it should return:

flink-table-api -> flink-core ->

apache-commons

 

6) Detects circular dependencies and displays a message about it

 

7) Additionally (if there is a lot of time left): adapt the program to work with different versions of each of the dependencies, for example:

hadoop-yarn:3.2.1 -> [hadoop-core:3.2.1, hadoop-dfs:3.2.1]

hadoop-hdfs:3.2.1 -> [apache-commons:1.12]

hadoop-hdfs:3.2.0 -> [apache-commons:1.11]

hadoop-core:3.2.1 -> [apache-commons:1.12]

hadoop-core:3.2.0 -> [apache-commons:1.11]

apache-commons:1.10 -> []

apache-commons:1.11 -> []

apache-commons:1.12 -> [log4j:2.1.0]

flink-table-api:1.11.2 -> [flink-core:1.11.2, apache-calcite:2.13, junit:4]

flink-core:1.11.2 -> [apache-commons:1.10, joda-time:4.0.2, lombok:3.0.1]

lombok:3.0.1 -> []

joda-time:4.0.2 -> []

apache-calcite:2.13 -> [lombok:3.0.2]

flink-connectors:1.11.2 -> [flink-core:1.11.2, hbase:6.11, hadoop-yarn:3.2.1]

hbase:6.11 -> [apache-commons:3.2.1, joda-time:4.0.2


Task 3. The RGB Game

The game named "RGB" is a single-person game played on a 10 X 15 board. Each square contains a ball colored red (R), green (G), or blue (B).

Two balls belong to the same cluster if they have the same color, and one can be reached from another by following balls of the same color in the four directions up, down, left, and right. At each step of the game, the player chooses a ball whose cluster has at least two balls and removes all balls in the cluster from the board.

Then, the board is "compressed" in two steps:

1. Shift the remaining balls in each column down to fill the empty spaces. The order of the balls in each column is preserved.

2. If a column becomes empty, shift the remaining columns to the left as far as possible. The order of the columns is preserved. For example, choosing the ball at the bottom left corner in the sub-board below causes:

The objective of the game is to remove every ball from the board, and the game is over when every ball is removed or when every cluster has only one ball. The scoring of each game is as follows. The player starts with a score of 0. When a cluster of m balls is removed, the player's score increases by (m — 2)2. A bonus of 1000 is given if every ball is removed at the end of the game. You suspect that a good strategy might be to choose the ball that gives the largest possible cluster at each step, and you want to test this strategy by writing a program to simulate games played using this strategy. If there are two or more balls to choose from, the program should choose the leftmost ball giving the largest cluster. If there is still a tie, it should choose the bottommost ball of these leftmost balls.

 

Input

You will be given a number of games in the input. The first line of input contains a positive integer giving the number of games to follow. The initial arrangement of the balls of each game is given one row at a time, from top to bottom. Each row contains 15 characters, each of which is one of "R", "G", or "B", specifying the colors of the balls in the row from left to right. A blank line precedes each game.

 

Output

For each game, print the game number, followed by a new line, followed by information about each move, followed by the final score. Each move should be printed in the format:

 


Дата добавления: 2021-03-18; просмотров: 116; Мы поможем в написании вашей работы!

Поделиться с друзьями:






Мы поможем в написании ваших работ!