#P6180. [USACO15DEC] Breed Counting S

[USACO15DEC] Breed Counting S

Description

Farmer John has NN cows, numbered from 1N1 \ldots N from left to right, standing in a line.

All cows belong to one of three breeds, and each cow has a breed ID (only one of 1,2,31,2,3). FJ has QQ queries, and each query asks for the number of cows of each breed within a certain interval.

Input Format

The first line contains two integers N,QN, Q (1N,Q1051 \leq N, Q \leq 10^5).

The next NN lines each contain one integer. The ii-th integer represents the breed ID of the ii-th cow.

The next QQ lines each contain two integers a,ba, b, meaning the range of the ii-th query is [a,b][a,b].

Output Format

For each query, output three integers: the number of breed 11 cows, the number of breed 22 cows, and the number of breed 33 cows in the specified interval.

6 3
2
1
1
3
2
1
1 6
3 3
2 4
3 2 1
1 0 0
2 0 1

Hint

Translated by ChatGPT 5