Codeforces Round 433 (Div. 1, based on Olympiad of Metropolises)
E
Lada Malina
Codeforces
3400
原题
← D→
翻译中…

After long-term research and lots of experiments leading Megapolian automobile manufacturer «AutoVoz» released a brand new car model named «Lada Malina». One of the most impressive features of «Lada Malina» is its highly efficient environment-friendly engines.

翻译中…

Consider car as a point in $*Oxy*$ plane. Car is equipped with $*k*$ engines numbered from $1$ to $*k*$. Each engine is defined by its velocity vector whose coordinates are $(*vx*_{*i*}, *vy*_{*i*})$ measured in distance units per day. An engine may be turned on at any level $*w*_{*i*}$, that is a real number between $- 1$ and $+ 1$ (inclusive) that result in a term of $(*w*_{*i*}·*vx*_{*i*}, *w*_{*i*}·*vy*_{*i*})$ in the final car velocity. Namely, the final car velocity is equal to

翻译中…

$(*w*_{1}·*vx*_{1} + *w*_{2}·*vx*_{2} + ... + *w*_{*k*}·*vx*_{*k*}, *w*_{1}·*vy*_{1} + *w*_{2}·*vy*_{2} + ... + *w*_{*k*}·*vy*_{*k*})$

翻译中…

Formally, if car moves with constant values of $*w*_{*i*}$ during the whole day then its $*x*$-coordinate will change by the first component of an expression above, and its $*y*$-coordinate will change by the second component of an expression above. For example, if all $*w*_{*i*}$ are equal to zero, the car won't move, and if all $*w*_{*i*}$ are equal to zero except $*w*_{1} = 1$, then car will move with the velocity of the first engine.

翻译中…

There are $*n*$ factories in Megapolia, $*i*$-th of them is located in $(*fx*_{*i*}, *fy*_{*i*})$. On the $*i*$-th factory there are $*a*_{*i*}$ cars «Lada Malina» that are ready for operation.

翻译中…

As an attempt to increase sales of a new car, «AutoVoz» is going to hold an international exposition of cars. There are $*q*$ options of exposition location and time, in the $*i*$-th of them exposition will happen in a point with coordinates $(*px*_{*i*}, *py*_{*i*})$ in $*t*_{*i*}$ days.

翻译中…

Of course, at the «AutoVoz» is going to bring as much new cars from factories as possible to the place of exposition. Cars are going to be moved by enabling their engines on some certain levels, such that at the beginning of an exposition car gets exactly to the exposition location.

翻译中…

However, for some of the options it may be impossible to bring cars from some of the factories to the exposition location by the moment of an exposition. Your task is to determine for each of the options of exposition location and time how many cars will be able to get there by the beginning of an exposition.

翻译中…

Input

翻译中…

The first line of input contains three integers $*k*, *n*, *q*$ ($2 ≤ *k* ≤ 10$, $1 ≤ *n* ≤ 10^{5}$, $1 ≤ *q* ≤ 10^{5}$), the number of engines of «Lada Malina», number of factories producing «Lada Malina» and number of options of an exposition time and location respectively.

翻译中…

The following $*k*$ lines contain the descriptions of «Lada Malina» engines. The $*i*$-th of them contains two integers $*vx*_{*i*}$, $*vy*_{*i*}$ ($- 1000 ≤ *vx*_{*i*}, *vy*_{*i*} ≤ 1000$) defining the velocity vector of the $*i*$-th engine. Velocity vector can't be zero, i.e. at least one of $*vx*_{*i*}$ and $*vy*_{*i*}$ is not equal to zero. It is guaranteed that no two velosity vectors are collinear (parallel).

翻译中…

Next $*n*$ lines contain the descriptions of factories. The $*i*$-th of them contains two integers $*fx*_{*i*}$, $*fy*_{*i*}$, $*a*_{*i*}$ ($- 10^{9} ≤ *fx*_{*i*}, *fy*_{*i*} ≤ 10^{9}$, $1 ≤ *a*_{*i*} ≤ 10^{9}$) defining the coordinates of the $*i*$-th factory location and the number of cars that are located there.

翻译中…

The following $*q*$ lines contain the descriptions of the car exposition. The $*i*$-th of them contains three integers $*px*_{*i*}$, $*py*_{*i*}$, $*t*_{*i*}$ ($- 10^{9} ≤ *px*_{*i*}, *py*_{*i*} ≤ 10^{9}$, $1 ≤ *t*_{*i*} ≤ 10^{5}$) defining the coordinates of the exposition location and the number of days till the exposition start in the $*i*$-th option.

翻译中…

Output

翻译中…

For each possible option of the exposition output the number of cars that will be able to get to the exposition location by the moment of its beginning.

翻译中…

Note

翻译中…

Images describing sample tests are given below. Exposition options are denoted with crosses, factories are denoted with points. Each factory is labeled with a number of cars that it has.

翻译中…

First sample test explanation:

翻译中…
  • Car from the first factory is not able to get to the exposition location in time.
  • Car from the second factory can get to the exposition in time if we set $*w*_{1} = 0$, $*w*_{2} = 1$.
  • Car from the third factory can get to the exposition in time if we set image, image.
  • Car from the fourth factory can get to the exposition in time if we set $*w*_{1} = 1$, $*w*_{2} = 0$.
翻译中…

image image

翻译中…

样例

Input #1
2 4 1
1 1
-1 1
2 3 1
2 -2 1
-2 1 1
-2 -2 1
0 0 2
Output #1
3
InputCopy OutputCopy
Input #2
3 4 3
2 0
-1 1
-1 -2
-3 0 6
1 -2 1
-3 -7 3
3 2 2
-1 -4 1
0 4 2
6 0 1
Output #2
4
9
0
InputCopy OutputCopy
题目信息
题号
853E
时间限制
5 s
内存限制
256 MB
标签
数据结构
计算几何

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。