#7475. [SWERC 2022] Controllers
[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 $ n $ ( $ 1 \le n \le 2\cdot 10^5 $ ) — 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 $ q $ lines. On line $ j $ print $ \texttt{YES} $ if the game is winnable using controller $ j $ , otherwise print $ \texttt{NO} $ .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