2 shunfurh shunfurh 于 2017.01.08 00:15 提问

PreQueL

Description

In some simplistic DBMS named PreQueL, the only column type allowed is CHAR(1) (a single character), and furthermore, its values are restricted to English upper-case letters ('A' to 'Z'). Table may contain up to 9 columns, numbered from 1 to 9. Tables themselves are named with lower-case English letters ('a' to 'z').

The only database query possible first joins all the tables, then selects some rows according to conditions in one of two forms: either < column>=< value> or < column1>=< column2>, for example a2=A or b1=c4. All conditions must hold simultaneously, as if they were connected by 'AND' operator.

You must write a PreQueL processor, which, given a tables and a set of conditions, will produce query result, i.e. those rows of a join satisfying all the conditions. Resulting rows must be sorted alphabetically.
Input

The first line of input file contains of two integers - number of tables T and number of conditions D.

Starting from the second line there are T tables represented with number of rows RN and number of columns CN in the first line of a table, which is followed by RN lines consisting of exactly CN characters each. D lines with conditions follow the whole set of tables.

The constraints are: 1 <= T <= 26, 1 <= D <= 50, 1 <= CN <= 9, 1 <= RN <= 1000.
Output

Output file contains result rows, one row per line. No input query will produce more than 1000 rows. The result rows are to be sorted alphabetically.
Sample Input

2 2
3 2
AX
BX
BY
2 3
ACD
BCC
a1=b1
a2=X
Sample Output

AXACD
BXBCC

1个回答

caozhy
caozhy   Ds   Rxr 2017.01.08 00:16
已采纳
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
More Python Programming for the Absolute Beginner
What better way is there to learn a programming language than with a game-oriented approach? If you ask the many readers that have made this book's prequel, PYTHON PROGRAMMING FOR THE ABSOLUTE BEGINNER, a bestseller, they'll tell you - there isn't one. MORE PYTHON PROGRAMMING FOR THE ABSOLUTE BEGINNER offers readers more practice, more exercises, and slightly more advanced instruction in Python programming, all while using the game-focused examples and projects that have proven to be both effective and fun. It picks up where its prequel leaves off, addressing data structures, file handling, exceptions, object oriented programming, GUI programming, multimedia programming, name spaces, and program planning. Following a deliberate, logical progression of topics that cover increasingly complex subject matter, this is a powerful resource that will arm readers with an in-depth knowledge of the Python language.
IPython+Interactive+Computing+and+Visualization+Cookbook,2nd-(2018).epub
We are becoming awash in the flood of digital data from scientific research, engineering, economics, politics, journalism, business, and many other domains. As a result, analyzing, visualizing, and harnessing data is the occupation of an increasingly large and diverse set of people. Quantitative skills such as programming, numerical computing, mathematics, statistics, and data mining, which form the core of data science, are more and more appreciated in a seemingly endless plethora of fields. Python, a widely-known programming language, is also one of the leading open platforms for data science. IPython is a mature Python project that provides scientist-friendly interactive access to Python. It is part of the broader Project Jupyter, which aims to provide high-quality environments for interactive computing, data analysis, visualization, and the authoring of interactive scientific documents. Jupyter is estimated to have several million users today. The prequel of this book, Learning IPython for Interactive Computing and Data Visualization Second Edition, Packt Publishing was published in 2015, two years after the first edition. It is a beginner-level introduction to data science and numerical computing with Python, IPython, and Jupyter. This book, the first edition of which was published in 2014, continues that journey by presenting more than 100 recipes for interactive scientific computing and data science. These recipes not only cover programming topics such as numerical computing, high-performance computing, parallel computing, and interactive visualization, but also data analysis topics such as statistics, data mining, machine learning, signal processing, graph theory, numerical optimization, and many others. This second edition is fully compatible with the latest versions of the platform and its libraries. It includes new recipes to better leverage the latest features of Python 3, and it introduces promising new projects such as JupyterLab, Altair, and Dask.
IPython Interactive Computing and Visualization Cookbook, 2nd-Packt2018.pdf
We are becoming awash in the flood of digital data from scientific research, engineering, economics, politics, journalism, business, and many other domains. As a result, analyzing, visualizing, and harnessing data is the occupation of an increasingly large and diverse set of people. Quantitative skills such as programming, numerical computing, mathematics, statistics, and data mining, which form the core of data science, are more and more appreciated in a seemingly endless plethora of fields. Python, a widely-known programming language, is also one of the leading open platforms for data science. IPython is a mature Python project that provides scientist-friendly interactive access to Python. It is part of the broader Project Jupyter, which aims to provide high-quality environments for interactive computing, data analysis, visualization, and the authoring of interactive scientific documents. Jupyter is estimated to have several million users today. The prequel of this book, Learning IPython for Interactive Computing and Data Visualization Second Edition, Packt Publishing was published in 2015, two years after the first edition. It is a beginner-level introduction to data science and numerical computing with Python, IPython, and Jupyter. This book, the first edition of which was published in 2014, continues that journey by presenting more than 100 recipes for interactive scientific computing and data science. These recipes not only cover programming topics such as numerical computing, high-performance computing, parallel computing, and interactive visualization, but also data analysis topics such as statistics, data mining, machine learning, signal processing, graph theory, numerical optimization, and many others. This second edition is fully compatible with the latest versions of the platform and its libraries. It includes new recipes to better leverage the latest features of Python 3, and it introduces promising new projects such as JupyterLab, Altair, and Dask.