← Home
write a go solution for A. Greedy Gridtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputA path in a grid is called greedy if it starts at the top-left cell and moves only to the right or downward, always moving to its neighbor with the greater value (or either if the values are equal).The value of a path is the sum of the values of the cells it visits, including the start and end.Does there exist an nxm grid of nonnegative integers such that no greedy path achieves the maximum value among all down/right paths?InputEach test contains multiple test cases. The first line contains the number of test cases t (1<=t<=5000). The description of the test cases follows.  The only line of each test case contains two integers n, m (1<=n,m<=100) — the number of rows and columns in the grid, respectively.OutputFor each test case, on a separate line output "YES" if the required grid exists, and "NO" otherwise.You can output the answer in any case (upper or lower). For example, the strings "yEs", "yes", "Yes", and "YES" will be recognized as positive responses.ExampleInput23 31 2OutputYES
NO
NoteIn the first test case, an example of a grid in which no greedy path achieves the maximum value out of all down/right paths is:  \begin{bmatrix} 3 & 5 & 1 \\ 2 & 1 & 2 \\ 5 & 4 & 3 \\ \end{bmatrix}  Let a_i,j denote the value of the cell in the i-th row and j-th column. The maximum value of a down/right path is a_1,1+a_2,1+a_3,1+a_3,2+a_3,3=17. This path isn't greedy because a_1,2 is greater than a_2,1; thus, a greedy path must move right in the first step. The maximum value of a greedy path is a_1,1+a_1,2+a_2,2+a_3,2+a_3,3=16.In the second test case, it can be proven that no grid satisfies the conditions.. Output only the code with no comments, explanation, or additional text.