← CSES Better

Fruits

ZCO · 2024 · Zonal Computing Olympiad · Problem 2

Open official problem ↗
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

grid · manhattan-distance · dynamic-updates

The organizer’s problem statement is available at the official source link.

grid distance

Find the farthest pair across two fruit classes

A query asks the largest shortest bee travel time between any U cell and any V cell; another operation changes one field’s fruit.

Problem grid; highlighted cells show the illustrated path
fruit A.fruit B
...
fruit A.fruit B
  1. 1

    Group cells by fruit

    Maintain the grid locations grouped by fruit type.
  2. 2

    Measure Manhattan distance

    Four-neighbor shortest travel equals Manhattan distance.
  3. 3

    Query the farthest pair

    For a query, maximize that distance across the two fruit groups; updates move one cell between groups.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 chars

Run output

Run your code to see output.