Limits 1s, 512 MB

Your friend Daenerys Targaryen wants to help the flood affected people. So she wants to store some data into a database to ease her works. But currently she doesn't have any DBMS installed. Besides she's scared to access internet because she thinks her PC can be hacked (just like HBO's).
So she asked for your help. You cannot use anything except an editor and compiler of your choice (Of course for security reasons).
Design a simple DBMS with basic functionalities of MySQL.

You have data of first_name, last_name, location, age and family_members of each flood victim. There are N flood victims.

Database name : People

Table name : people

Queries are:

  • mysql -u root -p People (to select the database)
  • use people (to select the table)
  • select * from people (to view all the records)
  • order by column_x asc (to sort in ascending order)
  • order by column_x desc (to sort in descending order)

For simplicity, no field will be longer than 18 characters.
Reserve 20 characters for each field, no matter what the size of field (or string whatever).
Place the names of the columns, values in the left.

Before any query, database should be selected first and then table too.
If not, print I can't write queries. So Shakib is a bad boy.

See sample input-output for clarification.

Input

The first line of the input is N (1 <= N <= 1000). Then N lines follow.
Each line contains data of one flood victim. Then receive and process queries until Lol:Exit is the query.

Output

Show the table according to the query. If query is wrong or not necessary print I can't write queries. So Shakib is a bad boy.

Sample

InputOutput
5
Humaun kabir Rajshahi 24 50
Didarul Islam Tangail 24 52
Sakibul Rumi Vulegesi 65 120
Shakir Romeo Jessore 65 350
Soummyo Avik Chittagong 120 350
mysql -u root -p People
use people
order by first_name asc
select * from people
use people
Lol:Exit
+--------------------+--------------------+--------------------+--------------------+--------------------+
| first_name         | last_name          | location           | age                | family_members     |
+--------------------+--------------------+--------------------+--------------------+--------------------+
| Didarul            | Islam              | Tangail            | 24                 | 52                 |
| Humaun             | kabir              | Rajshahi           | 24                 | 50                 |
| Sakibul            | Rumi               | Vulegesi           | 65                 | 120                |
| Shakir             | Romeo              | Jessore            | 65                 | 350                |
| Soummyo            | Avik               | Chittagong         | 120                | 350                |
+--------------------+--------------------+--------------------+--------------------+--------------------+
I can't write queries. So Shakib is a bad boy.

If any part (column) is told to sort, we need to care about only that part. Any other column should remain unchanged. Do compare only the part which is in the queries.

Submit

Login to submit.

Statistics

62% Solution Ratio
divby0Earliest, Aug '17
Kuddus.6068Fastest, 0.0s
divby0Lightest, 1.4 MB
NaimulShortest, 4955B
Toph uses cookies. By continuing you agree to our Cookie Policy.