TopCoder Marathon Match 35 用の起動関数
前回(http://d.hatena.ne.jp/Horiuchi_H/20080503/1209830474)に引き続き、MM35が始まったので Java用の visualizer用コードを下の方に張っておきます。
さて、今回の問題はゾンビがいっぱい居る部屋の中を脱出するというものです。10回までは触られても大丈夫だけど、その間に以下に早く脱出するかを競います。残りライフによるボーナスもあるので、できるだけゾンビを避けつつ、しかし最短距離で進もうということですね。ログインできる方は、以下のURLで問題が見れます。
http://www.topcoder.com/longcontest/?module=ViewProblemStatement&compid=8752&rd=12201
import java.io.IOException; public class BrownianZombies { public String move(int[] zx, int[] zy, int x, int y) { // とりあえず猪突猛進 return "RD"; } private static int nextInt() throws IOException { return Integer.parseInt(readToken()); } private static String readToken() throws IOException { StringBuilder builder = new StringBuilder(); while (true) { int i = System.in.read(); if (i < 0) throw new IllegalStateException(); char c = (char) i; if (c <= ' ') { if (builder.length() == 0) continue; break; } builder.append(c); } return builder.toString(); } public static void main(String[] args) { // for visualization tool try { BrownianZombies bz = new BrownianZombies(); int zombies = nextInt(); while (true) { int[] zx = new int[zombies]; for (int index = 0; index < zombies; index++) { zx[index] = nextInt(); } int[] zy = new int[zombies]; for (int index = 0; index < zombies; index++) { zy[index] = nextInt(); } int x = nextInt(); int y = nextInt(); String ret = bz.move(zx, zy, x, y); System.out.println(ret); System.out.flush(); } } catch (IOException e) { e.printStackTrace(); } } }