Downloads
In order to use the visualizer tool for testing your solution locally, you'll have to modify your solution
by adding the main method that interacts with the visualizer via reading data from standard input and
writing data to standard output. Since you do not change the implementation of methods init
and processOrder, this doesn't affect the way your solution works when being submitted to our server.
To simulate init call on server side, your program should read the following data from standard input
in this exact order (each integer/string is located in a separate line):
- Integer H indicating the number of elements in plate.
- Strings plate[0], plate[1], ..., plate[H-1], in this order.
- Integer K.
- Integer orderCnt.
Once this data is read, pass it to your implementation of init method.
To simulate processOrder call on server side, your program should read the following data from standard input in this exact
order (each integer/string is located in a separate line):
- Integer H indicating the number of elements in figure.
- Strings figure[0], figure[1], ..., figure[H-1], in this order.
- Integer income.
Once this data is read, pass it to your implementation of processOrder method and let ret be the return value. Write the
following data to standard output in this exact order (each integer in a separate line):
- Integer N indicating the number of elements in ret (it will be 0 or 5).
- Integers ret[0], ret[1], ..., ret[N-1] (nothing is written when ret is empty).
Make sure to flush the standard output after all this data is written.
In other words, you should implement the following pseudocode in the main method of your solution:
H = int(readLine())
for (i=0; i < H; i++)
plate[i] = readLine()
K = int(readLine())
orderCnt = int(readLine())
init(plate, K, orderCnt)
for (orderId=0; orderId < orderCnt; orderId++) {
H = int(readLine())
for (i=0; i < H; i++)
figure[i] = readLine()
income = int(readLine())
ret = processOrder(figure, income)
printLine(ret.length)
for (i=0; i < ret.length; i++)
printLine(ret[i])
flush(stdout)
}
In order to run the visualizer, you should use the following command:
java -jar Visualizer.jar -exec "<command>"
Here <command> is the command you would use to execute your solution. If your compiled solution is an executable file, the command will just
be the full path to it, for example, "C:\TopCoder\solution.exe" or "~/topcoder/solution". In case your compiled solution is to be run
with the help of an interpreter, for example, if you program in Java, the command will be something like "java -cp C:\TopCoder Solution".
Additionally you can use the following options (all are optional):
- -seed <value>. This allows to run the visualizer on the testcase generated using the given seed (by default it is 1).
- -novis. This option, if present, turns all visualization off, so you will only see your total income printed to the standard output. All subsequent
options only make sense when -novis is absent.
- -width <value>. You can use this to set the width of the vizualizer window (default is 750).
- -height <value>. This can be used to set the height of the vizualizer window (default is 750).
- -delay <value>. This option allows to set the delay between vizualizing consecutive orders, in milliseconds (default is 50).
- -waitkey. This option, if present, makes the visualizer wait for you to press a space key before displaying each next order (-delay option
is ignored in this case).
- -forceexit. By default, once the testcase is completely simulated, the visualizer will wait until you close its window. This option,
if present, forces it to exit immediately in this case.
You can print any debug information of your solution to the standard error stream and it will be forwarded to the standard output of the visualizer.
As a final piece of information, here's is the meaning of cell colors used by the visualizer:
- White cell is an available cell with the wood of good quality.
- Brown cell contains the wood of bad quality.
- Red cells belong to the last figure that your solution has cut.
- The cells of each figure you have cut will be marked with the same color. Colors will be chosen so that neighboring figures are always colored differently.
Besides that, colors do not have any other meaning, i.e., for example, there's no difference between blue and green figures.
For more information on using visualizers, please check the following recipe draft
from TopCoder Cookbook.