luogu#P5238. 整数校验器

整数校验器

Problem Description

Sometimes you need to solve this kind of problem: determine whether a number xx is valid.

xx is valid if and only if it satisfies the following conditions:

  • The format of xx is valid. A valid integer is either 00, or is formed by concatenating, in order, an optional minus sign, a digit from 11 to 99, and then some digits from 00 to 99.
  • xx is within the interval [l,r][l, r] (i.e., lxrl \le x \le r).

You need to implement such a validator. Given ll and rr, you will check multiple times whether each xx is valid.

Input Format

The first line contains three integers l,r,Tl, r, T, indicating that the validator checks the interval [l,r][l, r], and there are TT values of xx to be checked.

The next TT lines each contain one xx, the number to be checked. It is guaranteed that the length of xx is at least 11 and it consists only of '0'~'9' and '-', and '-' appears only as the first character.

Output Format

Output TT lines in total, each containing one integer representing the validation result for each xx.

The results are defined as follows: 00 means xx is valid; 11 means the format of xx is invalid; 22 means the format of xx is valid but xx is not within the interval [l,r][l, r].

-3 3 4
0
00
-0
100000000000000000000
0
1
1
2

Hint

For 100%100\% of the testdata, 0T5120 \le T \le 512, and l,rl, r are within the range of 64-bit signed integers (i.e., 263lr2631-2^{63} \le l \le r \le 2^{63} - 1).

The input file size is guaranteed to be no more than 128KB\text{128KB}. The testdata is generated under Linux, and there is no '\r' character.

Below are some special constraints (they do not include each other):

  • For 5%5\% of the testdata, T=0T = 0.
  • For 25%25\% of the testdata, it is guaranteed that the format of xx is always valid.
  • For 30%30\% of the testdata, it is guaranteed that if the format of xx is valid, then xx is within the range of 64-bit signed integers.

There is an unscored hack test point, intended to test the handling of long long boundary values. If you get UnAC with 100 points, it may be because you did not consider this case.

Translated by ChatGPT 5