Hide

Problem E
Find my Family

/problems/findmyfamily/file/statement/en/img-0001.jpg
CC-BY 2.0 By Ivan on Flickr

You are looking for a particular family photo with you and your favorite relatives Alice and Bob. Each family photo contains a line-up of n people. On the photo you’re looking for, you remember that Alice, who is taller than you, was somewhere on your left from the perspective of the photographer. Also, Bob who is taller than both you and Alice, was standing somewhere on your right.

Since you have a large number of family photos, you want to use your computer to assist in finding the photo. Many of the photos are quite blurry, so facial recognition has proven ineffective. Luckily, the Batch Apex Photo Classifier, which detects each person in a photo and outputs the sequence of their (distinct) heights in pixels, has produced excellent results. Given this sequence of heights for k photos, determine which of these photos could potentially be the photo you’re looking for.

Input

  • The first line contains 1k1000, the number of photos you have to process.

  • Then follow two lines for each photo.

    • The first line contains a single integer 3n3105, the number of people on this photo.

    • The second line contains n distinct integers 1h1,,hn109, the heights of the people in the photo, from left to right.

It is guaranteed that the total number of people in all photos is at most 3105.

Output

  • On the first line, output the number of photos k that need further investigation.

  • Then print k lines each containing a single integer 1ain, the sorted indices of the photos you need to look at.

Sample Input 1 Sample Output 1
1
3
2 1 3
1
1
Sample Input 2 Sample Output 2
4
4
140 157 160 193
5
15 24 38 9 30
6
36 12 24 29 23 15
6
170 230 320 180 250 210
2
2
4
Hide

Please log in to submit a solution to this problem

Log in