## IOI '13 P2 - Art Class (Standard I/O)

View as PDF

Points: 20 (partial)
Time limit: 60.0s
Memory limit: 64M

Problem type

You have an Art History exam approaching, but you have been paying more attention to informatics at school than to your art classes! You will need to write a program to take the exam for you.

The exam will consist of several paintings. Each painting is an example of one of four distinctive styles, numbered , , and .

Style contains neoplastic modern art. For example:

Style contains impressionist landscapes. For example:

Style contains expressionist action paintings. For example:

Style contains colour field paintings. For example:

Your task is, given a digital image of a painting, to determine which style the painting belongs to.

The IOI judges have collected many images in each style. Nine images from each style have been chosen at random and included in the task materials on your computer, so that you can examine them by hand and use them for testing. The remaining images will be given to your program during grading.

The image will be given as an grid of pixels. The rows of the image are numbered from top to bottom, and the columns are numbered from left to right.

The pixels are described using two-dimensional arrays , and , which give the amount of red, green and blue respectively in each pixel of the image. These amounts range from (no red, green or blue) to (the maximum amount of red, green or blue).

#### Input Specification

The first line of input will contain the integer , the number of test cases to follow.

For each test case:

• The first line will contain the two integers and , the height and width of the image.
• The next lines will each contain integers. Each integer will describe a pixel using the default RGB color model (see below for conversion instructions).

#### Output Specification

For every test case, output a line containing a single integer denoting the style of the image, which must be or , as described above.

#### Sample Tests

Individual sample test cases for the above images can be found here for you to analyse (Right click > Save link as):

#### Interpreting Colors

The standard conversion scheme with RGB colors uses the formula: RGB = (R<<16)|(G<<8)|B, where and are values from to inclusive, << is the bitshift-left operator, and | is the bitwise-OR operator. To obtain the RGB values from an individual encoded integer pixel, use the following functions:

##### C/C++
int getR(int RGB) { return (RGB >> 16) & 0xFF; }

int getG(int RGB) { return (RGB >> 8) & 0xFF; }

int getB(int RGB) { return RGB & 0xFF; }

##### Pascal
function getR(RGB: longint): integer;
begin getR := (RGB shr 16) and $FF; end; function getG(RGB: longint): integer; begin getG := (RGB shr 8) and$FF; end;

function getB(RGB: longint): integer;
begin getB := RGB and \$FF; end;


#### Scoring

Suppose you correctly classify percent of the images (so ):

• If then you will score points.
• If then you will score between and points, on a linear scale.
Specifically, your score will be , rounded down to the nearest integer.
• If then you will score between and points, on a linear scale.
Specifically, your score will be , rounded down to the nearest integer.
• If then you will score points.

#### Experimentation

The sample grader on your computer will read input from the file artclass.jpg. This file must contain an image in JPEG format.

You are allowed to use any available graphics processing applications to study the images, but this is not necessary to solve the problem.

#### Language Notes

C/C++ You must #include "artclass.h".

Pascal

You must define the unit ArtClass. All arrays are numbered beginning at (not ).

See the solution templates on your machine for examples.