MWC '15 #4 P3: Salt

View as PDF

Points: 6 (partial)
Time limit: 0.1s
Java 8 0.5s
Python 0.5s
Memory limit: 256M

Author:
Problem type
Allowed languages
Ada, Assembly, Awk, Brain****, C, C#, C++, COBOL, CommonLisp, D, Dart, F#, Forth, Fortran, Go, Groovy, Haskell, Intercal, Java, JS, Kotlin, Lisp, Lua, Nim, ObjC, OCaml, Octave, Pascal, Perl, PHP, Pike, Prolog, Python, Racket, Ruby, Rust, Scala, Scheme, Sed, Swift, TCL, Text, Turing, VB, Zig

After failing his accounting, physics and engineering tests all in one day, aurpine 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 at output salty, otherwise output bland.
• 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.

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.

• commented on April 16, 2016, 1:37 p.m. edited

The explanation says there are 4 grains with a y coordinate of 5, but in fact there are 2.

• commented on April 16, 2016, 1:46 p.m.

Nice catch. Thanks! Problem statement fixed.

• commented on April 16, 2016, 1:33 p.m.

The second batch has been fixed. (there were duplicates) Sorry.

• commented on April 17, 2016, 4:42 p.m.

I can't believe you've done this.