#P15599. [ICPC 2020 Jakarta R] Token Distance
[ICPC 2020 Jakarta R] Token Distance
题目描述
You are playing a board game with squares numbered from to (inclusive) and tokens numbered from to . Each token is located in one of the squares, and multiple tokens might be located in the same square. Initially, token is located in square . The distance of the two tokens is the difference between the square number where the first token is located and the square number where the second token is located.
For a set of tokens , we would like to check whether the tokens are well-separated as follows:
- Let be the list of tokens in sorted by increasing order of square number where the token is located. If several tokens are located in the same square, then these tokens are sorted by increasing order of token number.
- If there are less than three tokens in , then the tokens are well-separated.
- Otherwise, the tokens are well-separated if and only if the distance between two neighbouring tokens in is the same. Two tokens are neighbouring if their indices in differ by one.
You would like to perform operations of either one of these types:
- Move token to square .
- Report whether the set of tokens numbered from to (inclusive) are well-separated.
输入格式
Input begins with a line containing two integers: (; ) representing the number of tokens and the number of operations, respectively. The next line contains integers: () representing the initial square location of the tokens. The next lines each contains one of the following input format representing the operation you should perform.
- (; )
Move token to square . - ()
Output whether the set of tokens numbered from to (inclusive) are well-separated.
There will be at least one operation of the second type.
输出格式
For each operation of the second type in the same order as input, output in a line a string "YES" (without quotes) or "NO" (without quotes) whether the set of tokens numbered from to (inclusive) are well-separated.
5 7
1 1 1 10 1
2 1 3
2 1 5
1 5 4
1 3 7
2 2 4
2 2 5
2 4 5
YES
NO
NO
YES
YES
提示
Explanation for the sample input/output #1
- Initially, the tokens are located in the square numbered .
- For the first operation, the distance between two neighbouring tokens in is and . Therefore, the tokens are well-separated.
- For the second operation, the distance between two neighbouring tokens in is , and . Therefore, the tokens are not well-separated.
- After the third and fourth operations, the tokens are located in the square numbered .
- For the fifth operation, the distance between two neighbouring tokens in is and . Therefore, the tokens are not well-separated.
- For the sixth operation, the distance between two neighbouring tokens in is , and . Therefore, the tokens are well-separated.
- For the seventh operation, has less than three tokens. By definition, the tokens are well-separated.