MWC '15 #4 P3: Salt
View as PDFAfter failing his accounting, physics and engineering tests all in one day, has decided to give you a problem! The problem is as follows.
There are  grains of salt, labelled 
 to 
. The 
th grain is located at the coordinate 
. Two grains won't occupy the same coordinate (because that's crazy!).
You are to answer  queries. There are two types of queries.
1 x y– if there is a piece of salt atoutput
salty, otherwise outputbland.2 X x– output the number of pieces of salt with an x-coordinate of.
2 Y y– output the number of pieces of salt with a y-coordinate of.
Input Specification
Input will initiate with two space separated integers  and 
 on a single line.
 lines follow with two space separated integers, 
 and 
, the coordinate of the 
th grain of salt.
 lines follow, in the queries form explained above.
Note: fast input may be required.
Constraints
Subtask 1 [10%]
Subtask 2 [30%]
Subtask 3 [60%]
Output Specification
 lines, one for each query.
Sample Input
5 4
1 2
3 5
4 3
4 5
4 7
1 2 1
1 1 2
2 X 4
2 Y 5
Sample Output
bland
salty
3
2
Explanation for Sample Output
There is no grain of salt at . There is a grain of salt at 
. There are 3 grains with an x-coordinate of 4. There are 2 grains with a y-coordinate of 5.
Comments