9046: OIL

内存限制:1024 MB 时间限制:8 S
题面:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述




Given a sequence of integers a1,…,ana_1,\dots,a_na1,,an , you need to process mmm operations.
In an operation xxx , you need to change a1,a2,…,axa_1,a_2,\dots,a_xa1,a2,,ax to ax,…,a2,a1a_x,\dots,a_2,a_1ax,,a2,a1 , and then query how many different kkk satisfies that there exists i,ji,ji,j that 1≤i≤x<j≤n1\le i\le x<j\le n1ix<jn s.t. ai=aj=ka_i=a_j=kai=aj=k .
Operations are NOT independent.

There is no 1≤i<j<k<l≤n1\le i<j<k<l\le n1i<j<k<ln s.t. ai=aj=ak=ala_i=a_j=a_k=a_lai=aj=ak=al
1≤ai≤n1\le a_i\le n1ain
1≤x≤n1\le x\le n1xn
1≤n,m≤3×1051\le n,m\le 3\times 10^51n,m3×105

输入格式

The first line contains two integers n,mn,mn,m .
The next line contains nnn integers a1,…,ana_1,\dots,a_na1,,an .
For the next mmm lines, each line contains an integer xxx , representing an operation.

输出格式

The first line contains two integers n,mn,mn,m .
The next line contains nnn integers a1,…,ana_1,\dots,a_na1,,an .
For the next mmm lines, each line contains an integer xxx , representing an operation.

输入样例 复制

6 5
4 2 5 5 4 4
2
5
5
3
6

输出样例 复制

1
1
1
2
0