Collinear Arrangements
시간 제한2초메모리 제한2048 MB
각 질의에 대해 한 점과 함께 한 직선 위에 있는 볼록 다각형 꼭짓점 쌍의 개수, 또는 두 점과 함께 한 직선 위에 있는 꼭짓점의 개수를 구한다.
문제
Given a convex polygon of points on a two-dimensional plane, answer queries, where each query has one of the following types:
- Given one point , find the number of pairs such that and the three points , , and are collinear.
- Given two points and , find the number of points such that and the three points , , and are collinear.
입력
The first line contains two integers and (, ) denoting the number of vertices in the given polygon and the number of queries, respectively.
Each of the following lines contains two integers, and , denoting a vertex of the polygon.
Each of the following lines contains one query, which is in one of the following formats:
- "
1", asking to calculate the number of pairs such that and the three points , , and are collinear. - "
2", asking to calculate the number of points such that and the three points , , and are collinear.
It is guaranteed that:
- for all points and queries;
- the polygon vertices are given in counter-clockwise order;
- the polygon is convex (in particular, no three vertices are collinear);
- for each query, the given points and the polygon vertices do not coincide;
- the number of queries in the first format does not exceed .
출력
For each query, output a line containing a single integer: the answer to the query.
힌트
- For the first query, the only pair is since , and are collinear.
- For the second query, the only point is since , , and are collinear.
- For the third query, the two pairs are and .