2336: 起止位置

内存限制:128 MB 时间限制:1.000 S
评测方式:文本比较 命题人:
提交:0 解决:0

题目描述

有 lns="http://www.w3.org/1998/Math/MathML"> 位同学按照年龄从小到大排好队。

王老师想要查询,年龄为 lns="http://www.w3.org/1998/Math/MathML"> 的同学,在队伍中首次出现的位置和最后一次出现的位置;如果队伍中不存在年龄为 lns="http://www.w3.org/1998/Math/MathML"> 的同学,请输出 lns="http://www.w3.org/1998/Math/MathML">1

由于人数太多,一个一个数,太慢啦,请你编程求解。

请注意:本题中王老师查询年龄 lns="http://www.w3.org/1998/Math/MathML"> 出现的起止位置,并不是查询了 lns="http://www.w3.org/1998/Math/MathML">1 次,而是查询了 lns="http://www.w3.org/1998/Math/MathML"> 次。

比如:

假设有 lns="http://www.w3.org/1998/Math/MathML">6 位同学的年龄为:lns="http://www.w3.org/1998/Math/MathML">1 lns="http://www.w3.org/1998/Math/MathML">2 lns="http://www.w3.org/1998/Math/MathML">2 lns="http://www.w3.org/1998/Math/MathML">2 lns="http://www.w3.org/1998/Math/MathML">3 lns="http://www.w3.org/1998/Math/MathML">3,王老师查询了 lns="http://www.w3.org/1998/Math/MathML">4 个年龄,分别是 lns="http://www.w3.org/1998/Math/MathML">2 lns="http://www.w3.org/1998/Math/MathML">1 lns="http://www.w3.org/1998/Math/MathML">3 lns="http://www.w3.org/1998/Math/MathML">8 ,那么:

年龄为 lns="http://www.w3.org/1998/Math/MathML">2 的同学首次和最后一次出现的位置分别是:lns="http://www.w3.org/1998/Math/MathML">2 lns="http://www.w3.org/1998/Math/MathML">4

年龄为 lns="http://www.w3.org/1998/Math/MathML">1 的同学首次和最后一次出现的位置分别是:lns="http://www.w3.org/1998/Math/MathML">1 lns="http://www.w3.org/1998/Math/MathML">1

年龄为 lns="http://www.w3.org/1998/Math/MathML">3 的同学首次和最后一次出现的位置分别是:lns="http://www.w3.org/1998/Math/MathML">5 lns="http://www.w3.org/1998/Math/MathML">6

年龄为 lns="http://www.w3.org/1998/Math/MathML">8 的同学首次和最后一次出现的位置分别是:lns="http://www.w3.org/1998/Math/MathML">1 lns="http://www.w3.org/1998/Math/MathML">1

输入

第一行包含整数 lns="http://www.w3.org/1998/Math/MathML"> 和 lns="http://www.w3.org/1998/Math/MathML"> ,表示队伍中的总人数和询问个数。

第二行包含 lns="http://www.w3.org/1998/Math/MathML"> 个整数(整数的值均在 lns="http://www.w3.org/1998/Math/MathML">110000 范围内),表示队伍中每个人的年龄。

接下来 lns="http://www.w3.org/1998/Math/MathML"> 行,每行包含一个整数 lns="http://www.w3.org/1998/Math/MathML"> ,表示一次询问的值。

输出

共 lns="http://www.w3.org/1998/Math/MathML"> 行,每行包含两个整数,表示所求年龄在队伍中的起始位置和终止位置。

如果数组中不存在该元素,则返回 -1 -1

样例输入 复制

6 3
1 2 2 2 3 3
2
1
8

样例输出 复制

2 4
1 1
-1 -1

提示

数据范围

lns="http://www.w3.org/1998/Math/MathML">1100000,110000,110000