結果

問題 No.331 CodeRunnerでやれ
ユーザー GrenacheGrenache
提出日時 2015-12-25 21:53:34
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 2,196 bytes
コンパイル時間 3,564 ms
コンパイル使用メモリ 74,928 KB
実行使用メモリ 77,296 KB
平均クエリ数 451.24
最終ジャッジ日時 2023-09-23 08:38:54
合計ジャッジ時間 13,142 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 273 ms
69,608 KB
testcase_01 AC 270 ms
70,108 KB
testcase_02 AC 315 ms
71,468 KB
testcase_03 AC 496 ms
73,008 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 795 ms
75,880 KB
testcase_07 AC 340 ms
70,528 KB
testcase_08 AC 698 ms
75,200 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.Scanner;


public class Main_yukicoder331 {

	static Scanner sc;
	static Printer pr;
    static boolean[][] used;
    static int[] dx = {0, 1, 0, -1};
    static int[] dy = {1, 0, -1, 0};

    public static void main(String[] args) {
        sc = new Scanner(System.in);
        pr = new Printer(System.out);

        used = new boolean[60][60];

        @SuppressWarnings("unused")
		String s = sc.nextLine();

        dfs(30, 30, 0);

        sc.close();
    }

    private static void dfs(int x, int y, int d) {
    	used[x][y] = true;
    	for (int i = 0; i < 4; i++) {
    		int tmpx = x + dx[(d + i) % 4];
    		int tmpy = y + dy[(d + i) % 4];
    		int tmpd = (d + i) % 4;

    		if (!used[tmpx][tmpy] && go("F") > 0) {
    			dfs(tmpx, tmpy, tmpd);
    			go("B");
    		}
			go("R");
    	}
	}

	static int go(String cmd) {
    	pr.println(cmd);
    	pr.flush();

    	String s = sc.nextLine();

    	if (s.equals("Merry Christmas!")) {
    		System.exit(0);
    	}

    	int f = Integer.parseInt(s);
    	while (f == 20151224) {
    		go("F");
    	}

    	return f;
    }

    /*
	@SuppressWarnings("unused")
	private static class Scanner {
		BufferedReader br;
		Iterator<String> it;

		Scanner (InputStream in) {
			br = new BufferedReader(new InputStreamReader(in));
		}

		String next() throws RuntimeException  {
			try {
				if (it == null || !it.hasNext()) {
					it = Arrays.asList(br.readLine().split(" ")).iterator();
				}
				return it.next();
			} catch (IOException e) {
				throw new IllegalStateException();
			}
		}

		int nextInt() throws RuntimeException {
			return Integer.parseInt(next());
		}

		long nextLong() throws RuntimeException {
			return Long.parseLong(next());
		}

		float nextFloat() throws RuntimeException {
			return Float.parseFloat(next());
		}

		double nextDouble() throws RuntimeException {
			return Double.parseDouble(next());
		}

		void close() {
			try {
				br.close();
			} catch (IOException e) {
//				throw new IllegalStateException();
			}
		}
	}
	*/

	private static class Printer extends PrintWriter {
		Printer(PrintStream out) {
			super(out);
		}
	}
}
0