IPSC Logo

Internet Problem Solving Contest

IPSC 2013

Problem I – Invisible cats

You are given a number of small grayscale images, each exactly 32 × 32 pixels in size. The images have been encrypted. The encryption is different for the easy and the hard subproblem. Both encryption types are described below.

There is a cat in the 21st image. There are also exactly ten other images with cats among the first 20 images. Find those ten cats!

Problem specification – easy subproblem

The pictures are encrypted in the following way: We picked a single random permutation on 32 elements. Then, for each picture we shuffled its columns using this permutation. That is, each column of pixels is still in its original order from top to bottom, but the order of columns is now different. (Note that we used the same permutation for all pictures.)

Problem specification – hard subproblem

The pictures are encrypted in the following way: We picked a single random permutation on 32 × 32 elements. Then, for each picture we shuffled its pixels using this permutation. That is, the set of pixels is now the same, they are just in different locations. (Again, note that we used the same permutation for all pictures.)

Input specification

For each subproblem you are given one set of encrypted images. Each set of images is provided in two different formats:

The first format is a ZIP archive that contains each encrypted image as a separate PGM file.

The second format is a single file that is formatted as follows: The first line contains a single integer: the number of images. For each image, you are then given 1024 integers, each in range from 0 (black) to 255 (white). The first 32 of these integers are the colors of the first row (left to right), the next 32 is the second row, and so on.

Output specification

Print ten whitespace-separated integers – the numbers of first ten pictures with cats, in ascending order. Do not use leading zeroes, even though the filenames in the ZIP archive have them.

Example

input
(a bunch of pictures)
output
1 2 3 4 5 6 7 8 9 20