Downloads


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 maxPercentage, worldMap and totalPopulation. To imitate one call of Population.queryRegion, you should print '?' character (in a separate line, quotes for clarity only), then print x1 y1 x2 y2 parameters (in a single line, separated with single spaces) and flush standard out. After each "call" written to standard out, you should read one line representing the return of the function. Once you're done with the queries, print the number of elements in your return (should always be equal to the number of elements in worldMap) followed by the elements of your return (each one in a separate line) and flush standard out.

To do this, you should implement the following pseudocode:

    int queryRegion(x1, y1, x2, y2)
    {   
    	printLine('?')
        printLine(x1 + " " + y1 + " " + x2 + " " + y2)
        flush(stdout)
        return int(readLine())
    }
    
    main()
    {   
    	maxPercentage = int(readLine())
        H = int(readLine())
        for (i=0; i<H; i++)
            worldMap[i] = readLine()
        totalPopulation = int(readLine())
        
        ret = mapPopulation(maxPercentage, worldMap, totalPopulation)
        printLine(ret.length)
        for (i=0; i<ret.length; i++)
            printLine(ret[i])
        flush(stdout)
    }

To run the visualizer with your solution, you should run:

java -jar tester.jar -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:

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.