PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN
#PS0000108. Đếm giống bò (Breed Counting)
HỌC THEO LỘ TRÌNH
1 lộ trìnhBài tập thuộc lộ trình
Mục lục đề ⌄
Đang đọc
Đếm giống bò (Breed Counting)
Breed Counting
Source: USACO
Version: Phuoc Hung OJ Extended
Problem Statement
John has cows in a row, numbered through . Breed IDs are for Holstein, for Guernsey and for Jersey. For each query , count cows of each breed at positions through , inclusive.
Input
The first line contains integers , the numbers of cows and queries.
The next lines each contain the breed ID of cow .
Each of the last lines contains integers .
Output
Print lines in query order. Each line contains three integers: the counts of breeds , in that order.
Subtasks
- Subtask 1 (20 points): ; ; ; .
- Subtask 2 (30 points): ; ; ; ; .
- Subtask 3 (50 points): ; ; ; .
Examples 1
Input
6 3
2
1
1
3
2
1
1 6
3 3
2 4
Output
3 2 1
1 0 0
2 0 1
Explanation
The breed IDs are . In , breed 1 occurs at 2, 3, 6; breed 2 at 1, 5; breed 3 at 4. Interval contains one breed-1 cow. Interval contains , hence counts .