#P5386. [Cnoi2019] 数字游戏
[Cnoi2019] 数字游戏
Description
Given a permutation of , and queries. Each query contains an integer quadruple , asking how many integer pairs satisfy:
- ;
- and for all , we have .
Input Format
The first line contains two integers and .
The second line contains integers, representing .
In the next lines, each line contains one query quadruple.
Output Format
Output lines, where each line is the answer to one query.
4 1
1 2 3 4
1 4 2 4
6
Hint
Subtask 1 ( points): .
Subtask 2 ( points): .
Translated by ChatGPT 5
京公网安备 11011102002149号