# What to Watch?

*English translation by SOTA – AI Community of the Russian original. Organisers who would like this translation removed can email sota.ai.community@gmail.com.*

All-Russian School Olympiad in Informatics 2025–2026, Final Stage<br>
“Artificial Intelligence” profile, Tour 2, Moscow, 25 March 2026<br>
Task A

## Statement

In an online cinema, a user needs to be recommended one film out of several possible options.

For this, the system selects five candidate films for the user and sets a rule by which one of them must be chosen. We will call such a selection task a **query**.

Each query is described by the following data:

- `user_id`: the user identifier;
- `query_type`: the query type, that is, the selection rule;
- $c_1$, $c_2$, $c_3$, $c_4$, $c_5$: the identifiers of five different candidate films.

Each row of the file `queries_A.csv` specifies one query: for the given user, one of the five proposed films must be chosen.

For each query, you need to output the `item_id` of the chosen film.

## Input format

Use the files attached to the task:

1. `queries_A.csv`
2. `items_A.csv`
3. `events_A.csv`
4. `item_meta_A.json`
5. `sessions_A.json`

## Notes

The task comes with the file `baseline_A.ipynb`, which contains an example of reading the input files, filtering the queries by type for each subtask, and a detailed description of the data.

## Output format

You need to output a CSV file with the header

`query_id,item_id`

For each `query_id` belonging to the corresponding subtask, the answer must contain exactly one row. There must be no extra rows.

## Scoring

The maximum score for each subtask is 20.

A solution is considered correct if, for each `query_id` belonging to the corresponding subtask, the correct `item_id` according to the rules of the task is given.

The final score for the task is based on the **best** submission.

## A1. Subtask 1

When solving this subtask, filter the rows of `queries_A.csv`, keeping only the queries of type `favorite_genre`, and output answers only for them.

For a `favorite_genre` query, the genre of each of the five candidates is taken, and then, for this genre, the sum of the weights of all events of the given user on films of the same genre is computed, where

- `open = 1`
- `finish = 2`
- `like = 3`

The candidate for whose genre this sum is the largest is chosen.

In case of a tie:

1. the film with the smaller `duration`;
2. the film with the smaller `item_id`.

## A2. Subtask 2

When solving this subtask, filter the rows of `queries.csv`, keeping only the queries of type `actor_match`, and output answers only for them.

For each `actor_match` query, the set `watched_actors` is formed from the actors of the films that the user

1. Either watched: `finish`;
2. Or marked as liked: `like`.

Only the actors from the `actors` field of the file `item_meta_A.json` are considered.

If the `actors` field is missing, it should be treated as an empty list.

For a candidate, `score` equals the number of common elements of the sets:

the set of actors of this candidate; the set `watched_actors`.

In case of a tie, the film with the smallest `item_id` is chosen.

## A3. Subtask 3

When solving this subtask, filter the rows of `queries_A.csv`, keeping only the queries of type `next_in_session`, and output answers only for them.

For the user, consider all adjacent pairs of films $f_1 \to f_2$ extracted from all the `path` lists in the file `sessions_A.json`.

If `path` = $[x_1, x_2, \ldots, x_k]$, then the following pairs are extracted from it:

$$\begin{gathered}
x_1 \to x_2 \\
x_2 \to x_3 \\
\vdots \\
x_{k-1} \to x_k
\end{gathered}$$

For a candidate $f_2$, its score is the number of such pairs $f_1 \to f_2$ for which the user has ever finished watching the film $f_1$, that is, there is a `finish` event for it in the file `events_A.csv`.

Each occurrence of a pair in `sessions_A.json` is counted separately.

If the user has no suitable pairs, the score of every candidate is taken to be 0.

The candidate with the largest score is chosen.

In case of a tie, the film with the smallest `item_id` is chosen.
