Logo
(追記) (追記ここまで)

32000번 - Examination 2 서브태스크다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB106480.000%

문제

JOI-kun goes to IOI High School, where the final exam is held soon. In the exam, students will be tested on whether they can correctly calculate the value of an IOI function. An IOI function is a string obtained by one of the following six rules defined by IOI High School, which maps integers between 1ドル$ and 10ドル^9$ (inclusive) to boolean values, either True or False.

  1. Let $a$ be an integer between 1ドル$ and 10ドル^9$ (inclusive), then [a] is an IOI function (a is the string representation of $a$ in decimal notation). This IOI function maps integers greater than or equal to $a$ to True, and integers less than $a$ to False.
  2. Let f be an IOI function, then (f) is also an IOI function. This IOI function maps the same integers to True and False as f does.
  3. Let f be an IOI function, then !f is also an IOI function. This IOI function maps integers that f maps to True to False, and vice versa.
  4. Let f and g be IOI functions, then f&g is also an IOI function. This IOI function maps integers to True if both f and g map them to True, and to False otherwise.
  5. Let f and g be IOI functions, then fˆg is also an IOI function. This IOI function maps integers to True if exactly one of f or g maps them to True, and to False otherwise.
  6. Let f and g be IOI functions, then f|g is also an IOI function. This IOI function maps integers to True if at least one of f or g maps them to True, and to False otherwise.

If an IOI function is obtained using multiple rules, the rule with the higher number determines the boolean value that the IOI function maps integers to. For example, for [1]&[2]|[3], rule 6 is applied to f = [1]&[2] and g = [3] (rather than applying rule 4 to f = [1] and g = [2]|[3]). Additionally, for rules 4, 5, and 6, the rule is applied so that f becomes as long as possible. For example, for [4]ˆ[5]ˆ[6], rule 5 is applied to f = [4]ˆ[5] and g = [6] (rather than applying rule 5 to f = [4] and g = [5]ˆ[6]).

To prepare for the exam, JOI-kun has prepared an IOI function $S$ of length $N$ and intends to practice determining the boolean values that this IOI funcition maps $Q$ integers $X_1, X_2, \dots , X_Q$ to. He askes for your help, as you are proficient with handling IOI functions, to create a sample solution.

Write a program which, given $N,ドル $Q,ドル $S$ and $X_1, X_2, \dots , X_Q,ドル determines the boolean values that the IOI function $S$ maps integers $X_1, X_2, \dots , X_Q$ to.

입력

The input is given from Standard Input in the following format:

$N$ $Q$

$S$

$X_1$

$X_2$

$\vdots$

$X_Q$

출력

Print $Q$ lines to Standard Output. $i$-th line (1ドル ≤ i ≤ Q$) should contain a single boolean value which the IOI function $S$ maps the integer $X_i$ to.

제한

  • 1ドル ≤ N ≤ 1,円 000,円 000$.
  • 1ドル ≤ Q ≤ 200,円 000$.
  • $S$ is an IOI function of length $N$.
  • 1ドル ≤ X_i ≤ 10^9$ (1ドル ≤ i ≤ Q$).
  • $N,ドル $Q,ドル and $X_i$ (1ドル ≤ i ≤ Q$) are integers.

서브태스크

번호배점제한
15

$S$ does not contain & or |.

220

$Q = 1$.

310

$N ≤ 10,円 000$.

46

$S$ does not contain ! or ˆ.

512

When rule 4 or rule 6 was applied in the process of obtaining $S,ドル at least one of f or g was an IOI function obtained from rule 1.

620

$N ≤ 400,円 000$.

727

No additional constraints.

예제 입력 1

15 5
(![2]|[3])&![4]
1
2
3
4
5

예제 출력 1

True
False
True
False
False

For some of the IOI functions that appear in the process of obtaining $S$ according to the rules in the problem statement, the boolean values they map integers $X_i$ (1ドル ≤ i ≤ Q$) to are as shown in the following table.

$X_i$ ![2] [3] ![2]|[3] ![4] (![2]|[3])&![4]
1ドル$ True False True True True
2ドル$ False False False True False
3ドル$ False True True True True
4ドル$ False True True False False
5ドル$ False True True False False

This sample input satisfies the constraints of subtasks 3, 6 and 7.

예제 입력 2

20 4
(!![23])ˆ((([116])))
54
1
200
89

예제 출력 2

True
False
False
True

This sample input satisfies the constraints of subtasks 1, 3, 5, 6 and 7.

예제 입력 3

32 4
[2]|[5]&[1]|(([1000000000])|[7])
4
10
6
1

예제 출력 3

True
True
True
False

This sample input satisfies the constraints of subtasks 3, 4, 6 and 7.

힌트

출처

Contest > JOI Open Contest > JOI Open Contest 2024 1번

채점 및 기타 정보

  • 예제는 채점하지 않는다.
(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /