To use the visualizer for testing your solution locally, you'll have to adopt your solution to read
the parameters from standard in and write the output to standard out.
This doesn't affect the functioning of the solution you submit to our server.
-
Your program should first read the parameters slide, medStrength, killTime and spreadProb and pass them to runSim.
-
To imitate one call of Research.addMed, you should print "ADDMED" (uppercase, in a separate line, quotes for clarity only),
then print "x y" parameters (in a single line, separated with single space) and flush standard out.
After this, read one line containing the return value from standard in.
-
To imitate one call of Research.observe, you should print "OBSERVE" (uppercase, in a separate line, quotes for clarity only) and flush standard out.
After this, read the number of elements in the observed slide (will equal the number of elements in slide), followed by the elements of the slide (each one in a separate line).
-
To imitate one call of Research.waitTime, you should print "WAITTIME" (uppercase, in a separate line, quotes for clarity only),
then print "units" parameter (in a single line) and flush standard out.
After this, read one line containing the return value from standard in.
-
Once your solution returns from runSim, print "END" (uppercase, in a separate line, quotes for clarity only) and flush standard out. You don't print the return value of runSim.
To do this, you should implement the following pseudocode:
int addMed(x, y) {
printLine("ADDMED")
printLine(x + " " + y)
flush(stdout)
return int(readLine())
}
String[] observe() {
printLine("OBSERVE")
flush(stdout)
H = int(readLine())
for (i=0; i<H; i++)
slide[i] = readLine()
return slide
}
int waitTime(units) {
printLine("WAITTIME")
printLine(units)
flush(stdout)
return int(readLine())
}
main() {
H = int(readLine())
for (i=0; i<H; i++)
slide[i] = readLine()
medStrength = int(readLine())
killTime = int(readLine())
spreadProb = double(readLine())
runSim(slide, medStrength, killTime, spreadProb)
printLine("END")
flush(stdout)
}
To run the visualizer with your solution, you should run:
java ViralInfectionVis -exec "<command>" -seed <seed>
Here, <command> is the command to execute your program,
and <seed> is seed for test case generation.
Additionally you can use the following options:
-
-novis to turn off the visualization.
-
-scale to set the size of "pixel" (cell size) in visualization.
-
-debug to turn on debug output.
Finally, you can print any debug information of your solution to standard error,
and it will be forwarded to the standard out of the visualizer.
For more information on using visualizers, please check the following recipe draft
from TopCoder Cookbook (a Google Doc copy available here).
Note that this is not a troubleshooting thread, please use the match forum for questions instead.