#P15167. [SWERC 2022] Controllers
[SWERC 2022] Controllers
题目描述
You are at your grandparents' house and you are playing an old video game on a strange console. Your controller has only two buttons and each button has a number written on it.
Initially, your score is . The game is composed of rounds. For each , the -th round works as follows.
On the screen, a symbol appears, which is either (plus) or (minus). Then you must press one of the two buttons on the controller once. Suppose you press a button with the number written on it: your score will increase by if the symbol was and will decrease by if the symbol was . After you press the button, the round ends.
After you have played all rounds, you win if your score is .
Over the years, your grandparents bought many different controllers, so you have of them. The two buttons on the -th controller have the numbers and written on them. For each controller, you must compute whether you can win the game playing with that controller.
输入格式
The first line contains a single integer ( ) — the number of rounds.
The second line contains a string of length — where is the symbol that will appear on the screen in the -th round. It is guaranteed that contains only the characters and .
The third line contains an integer ( ) — the number of controllers.
The following lines contain two integers and each ( ) — the numbers on the buttons of controller .
输出格式
Output lines. On line print if the game is winnable using controller , otherwise print .
8
+-+---+-
5
2 1
10 3
7 9
10 10
5 3
YES
NO
NO
NO
YES
6
+-++--
2
9 7
1 1
YES
YES
20
+-----+--+--------+-
2
1000000000 99999997
250000000 1000000000
NO
YES
提示
In the first sample, one possible way to get score using the first controller is by pressing the button with numnber in rounds , , , , and , and pressing the button with number in rounds and . It is possible to show that there is no way to get a score of using the second controller.