#A. CS240 project Problem 1

    传统题 1000ms 256MiB

CS240 project Problem 1

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

Problem Statement

Consider an endlessly repeating sequence of keys, analogous to an infinite piano keyboard. This sequence follows a specific pattern that repeats indefinitely: wbwbwwbwbwbw. You need to determine if a continuous section of this sequence can be found which includes exactly W white keys (denoted by w) and B black keys (denoted by b).

Details

  • The pattern for the sequence is: wbwbwwbwbwbw.
  • Your task is to identify whether there is a substring in this infinite sequence that contains exactly W 'w' characters and B 'b' characters.

Constraints

  • N: An integer such that 0N100 \leq N \leq 10
  • W: An integer such that 0W1000 \leq W \leq 100
  • B: An integer such that 0B1000 \leq B \leq 100
  • The sum of W and B must be at least 1 (W+B1W + B \geq 1), ensuring that you are always looking for a non-empty segment.

Input

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

N
W1 B1
W2 B2
...
WN BN

Here, N denotes the number of queries. Each line after the first specifies a pair of integers Wi and Bi, which represent the numbers of 'w' and 'b' characters to check for in the string S respectively.

Output

For each query, if there is a contiguous substring in S that contains exactly Wi 'w' characters and Bi 'b' characters, output Yes; otherwise, output No.

F1 F2 ... FN

Sample Input 1

1
3 2

Sample Output 1

Yes

The first 15 characters of SS are wbwbwwbwbwbwwbw. You can take the 11-th through 15-th characters to form the string bwwbw, which is a substring consisting of three occurrences of w and two occurrences of b.

Sample Input 2

2
3 0
10 2

Sample Output 2

No No

The only string consisting of three occurrences of w and zero occurrences of b is www, which is not a substring of SS.

Sample Input 3

3
92 66
1 3
3 1

Sample Output 3

Yes No Yes

CS240 2024 Spring Project Problem

未参加
状态
已结束
规则
IOI
题目
4
开始于
2024-5-30 17:00
结束于
2024-6-24 23:59
持续时间
607 小时
主持人
参赛人数
99