cf/mirror

Permutation and Queries

CF
1619H2400· grandmaster4s256 MB⌨ stdin/stdout

Examples

Sample 1of 2
Input
5 4
5 3 4 2 1
2 3 1
2 1 2
1 1 3
2 1 2
Output
4
1
2
Sample 2of 2
Input
5 9
2 3 5 1 4
2 3 5
2 5 5
2 5 1
2 5 3
2 5 4
1 5 4
2 5 3
2 2 5
2 5 1
Output
3
5
4
2
3
3
3
1
1619H.cpp
loading editor…
Ln 11·137 BGNU C++20 (64)