Checklist VsOSh AI 2026 Municipal Stage (Moscow), grades 9–11 · Task 6
Heat Map
Russian title: Тепловая карта
Find a minimum-area sub-rectangle of a colour grid that contains all k colours.
The task
Slava's heat map is an n × m table of colours c_ij numbered 1 to k and is too large for his poster, so he wants to cut out a rectangular fragment that still contains at least one cell of every colour, with the smallest possible area. All k colours are guaranteed to occur.
Abridged and translated by SOTA from the official Russian materials. The official statement has the exact rules, and it wins wherever this summary differs.
In English
This task was published in Russian. SOTA translated its 4 files into English on 16 September 2026.
- Task statement Russian original of Task statement
- Official solution Russian original of Official solution
- Full paper (all tasks of the stage) Russian original of Full paper (all tasks of the stage)
- All answers and solutions of the stage Russian original of All answers and solutions of the stage
Read the task statement in English
Heat Map
English translation by SOTA – AI Community of the Russian original. Organisers who would like this translation removed can email [email protected].
Task 6 of the municipal stage (Moscow) of the All-Russian School Olympiad (VsOSh) 2025/26 in artificial intelligence, grades 9–11 (variant III). Original: tasks-ai-9-11-mun-msk-25-26.pdf.
Time limit: 1 second
Memory limit: 256 megabytes
Slava is preparing a poster for a conference. Unfortunately, his heat map does not fit on the poster at the moment: it is too large. So Slava decided to select some rectangular fragment of the current map and use it for the presentation. Slava's heat map looks like a table of rows and columns. The cell at the intersection of the -th row and the -th column has colour . There are colours in use, numbered from 1 to . An example of a similar map is shown on the right. Slava wants to show the whole range of values, so the selected fragment must contain at least one cell of each colour. At the same time, the young speaker wants to minimise the area of the map, because he needs to fit it on the poster.
[Figure: an example heat map, printed to the right of this text; see page 4 of the original PDF.]
Help him: find a rectangle that can be cut out of his map so that it contains cells of all colours. It is guaranteed that the original heat map contains cells of all colours.
Input format
The first line contains three natural numbers (, ).
Each of the next lines contains natural numbers ().
Output format
Output 4 numbers that define the rectangle to be cut out. The rectangle is given by its top and bottom rows (, ) and its left and right columns (, ). If there are several ways to cut out a chart of the smallest area, output any of them.
Examples
Standard input:
3 4 3
1 1 2 2
3 1 1 3
1 2 2 2
Standard output:
1 3 2 4
Note
[Figure: see page 4 of the original PDF. Transcription: the map of the example, with three dashed outlines marking rows 2–3 × columns 1–2 (red), rows 1–2 × columns 3–4 (orange) and rows 2–3 × columns 3–4 (purple).]
| column 1 | column 2 | column 3 | column 4 | |
|---|---|---|---|---|
| row 1 | 1 | 1 | 2 | 2 |
| row 2 | 3 | 1 | 1 | 3 |
| row 3 | 1 | 2 | 2 | 2 |
All possible ways to cut out a chart of the smallest area for the first example.
Scoring criterion: exact match of the answer — 100 points
Maximum score for the task — 100
Translated by SOTA. The Russian original is the official version and wins wherever the two differ. Translated from the statement and answer PDFs of the Moscow municipal stage (grades 9–11) on vos.olimpiada.ru. The two figures are described in text (the example grid as a table), with links to the original pages. If you organise this olympiad and would like the translation removed, email [email protected] and we will take it down.
At a glance
- You get
- Standard input: n, m, k (1 ≤ n, m ≤ 250, 1 ≤ k ≤ 20), then n lines of m integers
c_ij(1 ≤c_ij≤ k). - You submit
- Four numbers x₁, y₁, x₂, y₂ (top and bottom rows, left and right columns) of any minimum-area rectangle.
- Scoring
- Checked answer; 100 points maximum.
- Rules
- Time limit 1 s; memory limit 256 MB.
- Format
- Municipal stage (Moscow), 17 December 2025, grades 9–11; individual; 180 minutes; answers and programs submitted to an online testing system; maximum 600 points for the paper.