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
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
Step by step
Solved in 3 steps with 1 images