Lili and Bibi has just graduated from highschool. They’re now in the same university. As both are bestfriends since kindergarten, they chose to share a dormitory room. Right before the first day of college, they both live in the same room. Lili and Bibi both like to read. Each of them has collections of their favourite books. Of course they brought them there. Each book has descriptions: ID(integer), title(string), and author(string). Lili has N books, while Bibi has M books. They both sorted the books by its ID in ascending order. Sadly, there are only one bookshelf in the dormitory room. They both want to organize their books in one bookshelf, Of course in a sorted ID in ascending order. However, they consider the ID as the first priority of sorting factors, if two books has the same ID, they sort it by its title lexicographically in ascending order. Two books with the same ID may have a different title or author. Lili doesn’t have two books with the same ID, neither does Bibi. But they both can have books with the same ID and same title on each of their collections. If they both have books with the same ID and same title, Bibi let Lili to put her book first in the bookshelf. Bibi wants to know in which order for each of her books after their books are organized in the same bookshelf Format Input There are T testcases. Every testcase consists an integer N. Followed by N lines consist of IDAi , TitleAi , and AuthorAi which describes i-th book ID, i-th book title, and i-th book author respectively from Lili’s collection for each line. The next line consists an integer M. Followed by M lines consist of IDBi , TitleBi , and AuthorBi which describes i-th book ID, i-th book title, and i-th book author respectively from BiBi’s collection for each line. Format Output Output T testcases with format “Case #X:” as header, where X indicates the testcase number and then followed by M lines of an integer Ranki for each line where Ranki means in which order Bibi’s i-th books in the shelf for each line. Constraints • 1 ≤ T ≤ 3 • 1 ≤ N ≤ 50000 • 1 ≤ IDAi , IDBi ≤ 109 • 1 ≤ |T itleAi |, |AuthorAi |, |T itleBi |, |AuthorBi | ≤ 6 Sample Input (standard input) 2 2 1 Merry John 3 Happy Paul 3 2 Quiet Vann 4 Liber Primus 6 Ace Mike 2 1 Merry John 3 Happy Paul 3 1 Merry Jhon 3 Haapy Raul 5 Ace Mike   Sample Output (standard output) Case #1: 2 4 5 Case #2: 2 3

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Lili and Bibi has just graduated from highschool. They’re now in the same university.
As both are bestfriends since kindergarten, they chose to share a dormitory room. Right
before the first day of college, they both live in the same room.
Lili and Bibi both like to read. Each of them has collections of their favourite books. Of
course they brought them there. Each book has descriptions: ID(integer), title(string),
and author(string). Lili has N books, while Bibi has M books. They both sorted the
books by its ID in ascending order. Sadly, there are only one bookshelf in the dormitory
room. They both want to organize their books in one bookshelf, Of course in a sorted ID
in ascending order. However, they consider the ID as the first priority of sorting factors,
if two books has the same ID, they sort it by its title lexicographically in ascending order.
Two books with the same ID may have a different title or author. Lili doesn’t have two
books with the same ID, neither does Bibi. But they both can have books with the same
ID and same title on each of their collections. If they both have books with the same ID
and same title, Bibi let Lili to put her book first in the bookshelf.
Bibi wants to know in which order for each of her books after their books are organized
in the same bookshelf

Format Input
There are T testcases. Every testcase consists an integer N. Followed by N lines consist
of IDAi
, TitleAi
, and AuthorAi which describes i-th book ID, i-th book title, and i-th
book author respectively from Lili’s collection for each line. The next line consists an
integer M. Followed by M lines consist of IDBi
, TitleBi
, and AuthorBi which describes
i-th book ID, i-th book title, and i-th book author respectively from BiBi’s collection for
each line.
Format Output
Output T testcases with format “Case #X:” as header, where X indicates the testcase
number and then followed by M lines of an integer Ranki
for each line where Ranki
means in which order Bibi’s i-th books in the shelf for each line.
Constraints
• 1 ≤ T ≤ 3

• 1 ≤ N ≤ 50000
• 1 ≤ IDAi
, IDBi ≤ 109
• 1 ≤ |T itleAi
|, |AuthorAi
|, |T itleBi
|, |AuthorBi
| ≤ 6

Sample Input (standard input)
2
2
1 Merry John
3 Happy Paul
3
2 Quiet Vann
4 Liber Primus
6 Ace Mike
2
1 Merry John
3 Happy Paul
3
1 Merry Jhon
3 Haapy Raul
5 Ace Mike

 

Sample Output (standard output)
Case #1:
2
4
5
Case #2:
2
3
5

Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Unreferenced Objects
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education