Integral
Time limit2sMemory limit512 MB
Given f at a set of integer points, extend it to a monotone piecewise linear function so the integral from 0 to n equals y.
- Level
Hard8 of 10
- Topics
- Intervals
- Solved
- No attempts yet
Problem
For a positive integer , let be the real interval . A function is only partly specified: the values of are given at the points of a subset of .
The set has these properties:
- Every point of is an integer.
- Both endpoints and of belong to .
The function has these properties:
- At every integer point of , the value of is an integer.
- Between two consecutive points of , is monotone. If and are consecutive points of with , then or .
- At a point of that is not an integer, is the linear interpolation of and , that is, .
The values of at the integer points of are still yours to choose. ( can already contain every integer point of .) For a given , decide whether those values can be chosen so that , that is, so that the area under between and equals .
Input
The input holds several test cases and ends at the end of the file.
The first line of a test case has three integers , and : the length of the interval, the size of , and the value of . Each of the next lines describes at one point of with two integers and , meaning . The values of are not necessarily in increasing order.
Constraints
- the sum of over all test cases is at most
- , and the values of are distinct integers that include and
- , integer
- , integer
- for every assignment of values to at the integer points of that obeys the rules above
Output
For each test case, decide whether values can be assigned to at the integer points so that , that is, so that the area under between and equals .
If they cannot, print a line containing only the character N. If they can, print a line containing the character S followed by the values of at the integer points , in increasing order of . Separate the leading character and each value by one blank space. When more than one assignment works, print the one whose sequence of values is the smallest in lexicographic order.