#P16736. [GKS 2019 #E] Code-Eat Switcher
[GKS 2019 #E] Code-Eat Switcher
Problem Description
Umon is a foodie coder. Do you know what two activities that he loves the most? Of course, coding and eating! He always spends the whole day doing only those two activities. However, he thinks that some times of the day are better spent coding, and others are better spent eating.
To illustrate this problem, Umon divides his day into time slots. During the i-th time slot, if Umon codes 100% of the time, he will achieve units of coding. On the other hand, if he eats 100% of the time, he will achieve units of eating. But of course, Umon can also use only a fraction of the time for coding, and the remaining for eating. Formally, he will choose a real number (), code for of the time, and use the remaining time to eat. This way, he will achieve units of coding and units of eating. The total amount of coding Umon achieves for the day is simply the sum of all units of coding he achieved in each of the time slots. The total amount of eating is calculated in a similar way.
Umon needs to plan his schedule for the next days. On the i-th day, he needs to achieve at least a total amount of units of coding and units of eating. For each day, determine whether there is a way for Umon to achieve his target.
Input Format
The first line of input gives the number of test cases, . test cases follow. Each test case begins with a line containing two integers and , the number of days and the number of time slots in a day, respectively.
Then lines follow, each describing a time slot. The i-th line contains two integers and , the amount of coding units achieved if Umon codes for 100% of the time slot, and the amount of eating units achieved if he eats for 100% of the time slot, respectively.
Then lines follow, each describing a day. The i-th line contains two integers and , the minimal total amount of coding and eating that needs to be achieved on that day.
Output Format
For each test case, output one line containing Case #x: y, where x is the test case number (starting from 1) and y is a string with D characters, where the i-th character is Y if there exists a schedule that can fulfill the target for the i-th day, otherwise it should be N.
2
4 2
3 8
6 10
0 18
3 13
10 0
7 3
1 2
4 4
4 4
0 0
Case #1: YYNY
Case #2: Y
Hint
In the first sample case, there are 4 days and 2 time slots for each day.
- For day 1, Umon can just eat for both time slots, and therefore achieving a total of 0 units of coding and units of eating, thus reaching the target.
- For day 2, Umon can eat of the time for the first time slot, and use of the second time slot for coding and for eating, achieving a total of units of coding, and units of eating, thus reaching the target.
- For day 3, it is impossible to get a total of 10 units of coding.
- For day 4, there are an infinite amount of ways to achieve the target. One possible strategy is to code (and eat ) in the first time slot, then code (and eat ) in the second time slot. That strategy yields a total of units of coding, and units of eating.
Thus, the answer should be YYNY.
In the second sample case, note that the value of characteristics for the time slots may not necessarily be different from each other.
Limits
.
, for all .
, for all .
, for all .
, for all .
Test set 1 (Visible)
.
.
Test set 2 (Hidden)
For at least 75% of the test cases:
.
.
For all test cases:
.
.