Loteria
Time limit1sMemory limit512 MB
Decide whether K target parities can be chosen so that no non-empty subset of the given rows has column sums matching all of them.
- Level
Medium5 of 10
- Topics
- Math, Bit manipulation, Brute force, Implementation
- Solved
- No attempts yet
Problem
The BWS Loteria draw is held once a year. people enter it, and each of them picks numbers. Write for the -th number picked by the -th person. The organizers then pick positive integers of their own, called .
The winners are decided like this.
- A non-empty subset of the entrants is drawn at random.
- Add up the first number picked by every person in that subset and call the total . That is, is the sum of over the indices in the subset. Compute the same way.
- For every , check whether and have the same parity, meaning both are even or both are odd.
- If the parities agree for every , that set of people wins.
The organizers want to know whether they can pick so that no subset of the entrants wins.
Input
The first line contains the number of entrants and the count of numbers each person picks, . (, )
Each of the next lines contains the numbers picked by one person. Every picked number is an integer between and , inclusive.
Output
Print S if the organizers can pick so that no subset wins, and N otherwise.