← CSES Better

Fertilizer

INOI · 2024 · Indian National Olympiad in Informatics · 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

intervals · range-union · offline-queries

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

interval union

Union trips in a consecutive trip range

A crop-duster trip fertilizes an interval of fields; each query selects consecutive trip IDs and asks how many fields are covered.

trip field range 1
0–3
trip field range 2
1–4
merged union
2–5
  1. 1

    Select trip range

    Select trip indices X through Y.
  2. 2

    Merge field intervals

    Overlay their field intervals and merge overlaps.
  3. 3

    Count covered fields

    Return the number of distinct fields in the union.
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.