Type: Default 1000ms 256MiB

藤藤的序列

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

Description

给定一个长度为N的序列,每个位置上的数只可能是1231,2,3中的一种。

QQ次询问,每次给定两个数a,ba,b,请分别输出区间[a,b][a,b]里数字1231,2,3的个数。

Format

Input

第一行两个整数nnqq

接下来nn行表示nn个数字,且每个数字均为1231,2,3中的一种,

接下来qq行,每行两个数字aabb,表示询问区间[a,b][a,b]里数字1231,2,3的个数。

Output

对于每一次询问,每行输出三个用空格隔开的数字,分别表示区间内1,2,3出现的个数

Samples

样例输入

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

样例输出

3 2 1  
1 0 0  
2 0 1

Limitation

12%12\%的分数,n10,q10n \leq 10, q \leq 10

另有12%12\%的分数,n1000,q1000n \leq 1000, q \leq 1000

100%100\%的分数,n100000,q100000n \leq 100000, q \leq 100000

20250220周赛

Not Attended
Status
Done
Rule
IOI
Problem
7
Start at
2025-2-20 16:30
End at
2025-2-20 18:30
Duration
2 hour(s)
Host
Partic.
26