当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3699:miniSQL

题目描述

Joan is taking an internship at a company these days. Every day she is assigned tons of dull statistical jobs such as counting how many products made by the company values more than $100. In order to have more time to chat with the handsome intern nearby, she asks you to program a clever software that helps her get released from the onerous work.

The software should take as input a table of records together with several queries and for each query output all the records respectively.

输入解释

The first part of the input is a single line consisting of three integers, m(1 ≤ m ≤ 10), n(1 ≤ n ≤ 10000), k(1 ≤ k ≤ 100) indicating the number of columns in the table, the number of records and the number of queries.

The second part of the input is the description of the table, which consists of m lines. The i-th line of this part consists two strings in the format Column_Name Type which describes the i-th column of the table.

  • Column_Name contains only letters(a-zA-Z), digits(0-9) and underline(_).
  • Type is either "STR" or "INT" indicating the type of this column.

The third part of the input shows the content of the table which contains n lines. The i-th line of this part shows the i-th record in the table which consists of m items.

  • if the type of the i-th column is "INT", the i-th item will be a 32-bit integer.
  • if the type of the i-th column is "STR" , the i-th item will be a string containing only letters(a-zA-Z), digits(0-9) and underline(_).

The last part of the input gives the k queries which are similar to SQL select statements. The query is in the format select Column_List where Condition

  • Column_List contains a list of column names which are separated by a single comma. All the names occured in the description of the table.
  • Condition is in the format Column_Name Op Value
    • Column_Name is one of the column name in the description of the table.
    • if the column's type is "STR", Op is "=". Otherwise it may be "=", "<" or ">".
    • if the column's type is "STR", Value will be a quoted string containing only letters(a-zA-Z), digits(0-9) and underline(_). Otherwise it will be a 32-bit integer.

The size of the input will not exceed 1M bytes.

输出解释

For each query output a table and a blank line as Sample Output shows.

输入样例
3 10 4
SID INT
NAME STR
PRIZE INT
1000 Potion 50
1001 Phoenix_Down 150
1002 Remedy 300
1003 Dagger 320
1004 Rod 260
1005 Flame_Staff 1100
1006 Broad_Sword 330
1007 Fork 1100
1008 Javelin 880
1009 Cats_Claws 4000
select SID,NAME,PRIZE where PRIZE>100
select SID,SID where NAME="Dagger"
select PRIZE where NAME="Rod"
select SID,NAME,PRIZE where NAME="Excalibur"
输出样例

+-----------------------------+
| SID  |     NAME     | PRIZE |
|------|--------------|-------|
| 1001 | Phoenix_Down |  150  |
| 1002 |    Remedy    |  300  |
| 1003 |    Dagger    |  320  |
| 1004 |     Rod      |  260  |
| 1005 | Flame_Staff  | 1100  |
| 1006 | Broad_Sword  |  330  |
| 1007 |     Fork     | 1100  |
| 1008 |   Javelin    |  880  |
| 1009 |  Cats_Claws  | 4000  |
+-----------------------------+

+-------------+
| SID  | SID  |
|------|------|
| 1003 | 1003 |
+-------------+

+-------+
| PRIZE |
|-------|
|  260  |
+-------+

+--------------------+
| SID | NAME | PRIZE |
|-----|------|-------|
+--------------------+

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3699

最后修改于 2020-10-29T07:08:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
1000 65536