We have total n products available numbered from \(1\) to \(n\). Each product belongs to one of the \(k\) categories and one of the \(m\) brands. Each product also has a base earning power \(c\). All products in the same category can be of a different brand, and the same brand can have multiple products in various categories.
The solution arranges products on a stand. The stand represents a rectangle with \(h\) shelves (rows), each one containing \(w\) positions (columns). Any product can occupy any position on any shelf. Any product occupies a single position, and any position can hold only one product. It is allowed to leave some products unplaced, as well as leave some positions unoccupied.
The resulting arrangement must comply with the following requirements to satisfy the visual convenience. Consider category \(t\), where at least one product is already on the shelf. Then, all positions occupied by other products of the same category \(t\) should form a continuous rectangle. We can express it in a more formally. Let us number the shelves from top to bottom with numbers from \(1\) to \(h\), and positions on each shelf from left to right with numbers from \(1\) to \(w\). Let \(a_l\) and \(a_r\) be the smallest and the largest number of shelves that present at least one product of category \(t\). Let \(b_l\) and \(b_r\) be the smallest and the largest number of positions among presented products. Then for any shelf \( a \, (a_l \leq a \leq a_r) \) and any position \(b \, (b_l \leq b \leq b_r)\), position \(b\) on the shelf a should have a product in category \(t\).
Let \(h = w = 4\), and \(k = 3\). Consider the following arrangement (the numbers represent positions occupied by products from those categories; dots represent empty positions):
11.4
112.
..2.
..2.
This arrangement is correct because positions of products in categories 1, 2, and 4 form a continuous rectangle and there are no products of category 3.
Here’s another example:
1111
1231
1241
1111
This arrangement is incorrect, due to the fact that the products of category 1 do not occupy a continuous rectangle.
The first input line provides six integer numbers \(n, k, m, h, w, D_0\). The numbers have the following limitations:
The next \(n\) lines describe the product parameters. Each i-th line has three integer numbers \(t_i\), \(b_i\), and \( c_i \, (1 \leq t_i \leq k, 1 \leq b_i \leq m, 1 \leq ci \leq 1000) \) — correspondingly, category, brand, and the base earning power of the product.
The solution must output \(h\) lines, each line containing \(w\) integer numbers separated by space. The number in position \(j\) on the line \(i\) should be equal to 0 if the position \(j\) on the shelf \(i\) is empty, otherwise, it should be equal to the product’s number in this position.
It is guaranteed that every test in the tests set is generated using the following algorithm.
The following parameters are picked manually:
For each brand, the algorithm randomly selects up to 10 various categories for goods (the minimal possible amount of categories is 1). The number of products can be selected manually.
Then, \(n\) products are generated independently according to the following scheme:
The program will be run for every test in the tests set. Overall score equals to the sum of scores for each test in the tests set.
Solution is scored for each test with the following formula:
$$C = D_0 \sum_{j=1}^k \sqrt{\frac{q_j}{h \times w}} + \sum_{i=1}^n I_i c_i (1 + \log_2 A_i)$$
If the program ran out of time or the result was incorrect then the score for that test is \(C = 0\).
In the formula above, the following notation is used:
Let \( h = w = 4, \, n = 9, \, k = m = 3, \, D_0 = 50 \). SKU parameters are defined with the following arrays:
Consider the following arrangement method:
.567
.12.
.438
...9
Categories, brands and \(A_i\) are distributed in the following fashion:
.222 .113 .441
.11. .11. .44.
.113 .322 .122
...3 ...2 ...2
The values of \(q_j\) are equals to: \(q_1 = 4,\, q_2 = 3,\, q_3 = 2\). Variety bonus \(D \approx 64.328\). Effective profit \(E\) is equals to 91 and overall score is \(C = D + E \approx 155.328\).
Participants expected to send the submission’s code to the grading system. The file extension of submission determines the way the execution and the following evaluation will be performed.
There are two possible options:
This is similar to ACM ICPC scheme. One can use Python3, Java, or C++. The module is compiled to a binary executable and then tests are carried out. Solution should have one of the following file extensions: .py, .java, or .cpp.
Submission is expected to be a ZIP archive with all files necessary to execute the solution. The root directory of the archive must contain a metadata.json file with the following content:
{"image": "datasouls/python","entry_point": "python solution.py"}
Where image
is a field used to describe docker-image used as a base image to run your solution. The field entry_point
contains a command to start a solution. The current during runtime is the root of the archive (the same directory where metadata.json is located).
Solutions are executed in an isolated docker environment with imposed limitations on both available resources and execution time during testing.
The archive can contain compiled binary files, but the source code and detailed build instructions should be also present. All potentially winning solutions will be checked manually for reproducibility.
Solutions are executed in an isolated docker environment under the following conditions:
Cookies help us deliver our services. By using our services, you agree to our use of cookies.