No.8021 Database Practice
タグ : / 解いたユーザー数 75
作問者 :
koyumeishi
This is an experimental problem that tries running SQLite, which comes standard with Python, on yukicoder. There may be various bugs.
Problem Statement
There are $n$ points on the $xy$ plane.
These points are stored in an SQLite database with the following structure.
CREATE TABLE point( id INTEGER PRIMARY KEY, x INTEGER, y INTEGER);
>TABLE point +----+---+---+ | id| x| y| +----+---+---+ | 1| x1| y1| +----+---+---+ | 2| x2| y2| (略) | n| xn| yn| +----+---+---+You are given $q$ queries of the following form. Output SQLite statements that answer them.
- Output the number of points such that $x_l \leq x_i \leq x_h , y_l \leq y_i \leq y_h$.
Input
The information about the points is not disclosed, but it satisfies the following constraints.
$1 \leq n \leq 10^3$
$0 \leq x_i \leq 10^9$
$0 \leq y_i \leq 10^9$
All point coordinates are integers, and no two points exist at the same position.
$q$
${x_l}_1$ ${x_h}_1$ ${y_l}_1$ ${y_h}_1$
$\vdots$
${x_l}_n$ ${x_h}_n$ ${y_l}_n$ ${y_h}_q$
The queries satisfy the following constraints.
$1 \leq q \leq 10^3$
$0 \leq {x_l}_i \leq {x_h}_i \leq 10^9$
$0 \leq {y_l}_i \leq {y_h}_i \leq 10^9$
Output
Use one SELECT statement for each query. The result of the i-th SELECT statement is regarded as the answer to the i-th query.
Since ';' is used as the SQL statement separator, do not forget the ';' at the end of each line.
Statements other than SELECT may also be used.
This problem is a reactive problem. Do not forget to flush when outputting.
Note: The results of the queries are not returned to your program.
Sample
Sample 1
Input
This is an example where the judge's set of points is as follows.
(3, 2) (8, 2) (9, 8) (3, 1) (4, 4) (1, 4) (0, 4) (3, 7) (0, 8) (7, 2)
These are the given queries.
2 6 7 2 7 10 10 10 10
Output
First query: the only point such that 6 <= x <= 7, 2 <= y <= 7 is (7,2), so outputting a SELECT statement that returns 1 is judged as correct.
Second query: (10, 10) does not exist in the set of points, so outputting a SELECT statement that returns 0 is judged as correct.
SELECT count(*) FROM point WHERE x=7 AND y=2; SELECT count(*) FROM point WHERE x=10 AND y=10;
In reality the set of points is not disclosed, so you will need to be a little more clever.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。