Best Friends
InterviewTime limit2sMemory limit1024 MB
Process queries that toggle base stations on the plane and count the stations forming an acute triangle with (-x,0) and (x,0) for a given x.
- Level
Medium6 of 10
- Topics
- Geometry, Hash map, Binary search
- Solved
- No attempts yet
Problem
Beomsu and Yunseong are the best of friends. Their village is drawn on a two-dimensional coordinate plane. Beomsu lives in the positive direction of the x-axis and Yunseong lives in the negative direction, so they cannot meet in person. They mostly bond by playing games together.
Games need a communication link through a base station located on the coordinate plane. For smooth play, the link must be fast enough. A player can use the high-speed link only when Beomsu's position, Yunseong's position, and the base station's position form an acute triangle. The village changes every day, so the positions of the two friends and the base stations change constantly. You must process the following queries.
1: Beomsu is at and Yunseong is at . Print the number of base stations where the high-speed link is available.2: If there is no base station at , install one. If there is one, remove it. No base station is located on the x-axis.
Initially, no base stations are installed. Write a program that processes the queries correctly.
Input
The first line contains the number of queries .
Each of the next lines contains one query in one of the following forms.
1:2:
All given numbers are integers. At least one query of type 1 is given.
Output
For each query of type 1, print the answer on its own line, in the order the queries are given.