IntroductionNOTE:This match will be unrated and won't be a part TCO19 Marathon Competion.Learn More
You are given a typesetter and a set of 4 colored tapes for it ��� cyan, magenta, yellow and black. The typesetter has a feature of altering the font and its size, by replacing the letters. The replacement procedure takes time and you can apply it limited number of times
The task you are asked to implement is to paint an image by using the typesetter and paper.
You are given a reference image that you are going to reproduce. The idea is to type a number of layers, one on top of another, so that the resulting image is as close as possible to the reference image.
First, your solution is initialized. This is done by calling init method. The signature is as follows:
int init(int nRenders, int nFonts, int precision, int width, int height, int image)
Next, a method nextGlyph is called until it returns an empty array. The purpose of it is to retrieve the available font letter images. Each next call to the method receives the information about the letter requested during the previous call. The first call gets dummy parameters. The signature is:
int nextGlyph(int width, int height, int bitmask, int remainingMillis)
The return from this method should be formatted as follows:
It is suggested that you implement a state machine to match requested and received letters.
Finally, a method render is called for nRenders times. You received the value of nRenders from init(). This method should contain the core of your logic that attempts to replicate the image. The signature is:
int render(int iteration, int remainingMillis)
Your solution will be scored as follows. First, all the layers are summed together (in CMYK space).
Then the result image is compare to the one provided in init(). The comparison is done by splitting
both images into precision x precision squares, then counting the total intensity of each of the
4 colors in source and result boxes. The score is increased for each of the boxes by the following
amount: pow(1 - abs(actualSum - originalSum), 2),
Finally, score is divided by canvas area, and multiplied by 1,000,000.
In case of illegal return of any kind, the score is zero.
Overall score across test cases is calculated relatively, summing YOUR / BEST for each of the test cases, averaging and scaling to 1,000,000.
|-||nRenders will be in range [1..16].|
|-||nFonts will be in range [10..25].|
|-||precision will be in range [1..16].|
|-||Images used in tests were downloaded from random image at Wikipedia. Images which were not primarily photographic or photo-realistic, such as line drawings or photos of paintings, were discarded. Each dimension of each image will be between 250 and 800 pixels.|
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2020, TopCoder, Inc. All rights reserved.