結果
問題 | No.331 CodeRunnerでやれ |
ユーザー | Grenache |
提出日時 | 2015-12-25 22:02:22 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 613 ms / 5,000 ms |
コード長 | 2,270 bytes |
コンパイル時間 | 3,580 ms |
コンパイル使用メモリ | 75,400 KB |
実行使用メモリ | 73,568 KB |
平均クエリ数 | 409.41 |
最終ジャッジ日時 | 2023-09-23 23:02:20 |
合計ジャッジ時間 | 13,199 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 254 ms
69,900 KB |
testcase_01 | AC | 281 ms
71,736 KB |
testcase_02 | AC | 326 ms
70,740 KB |
testcase_03 | AC | 362 ms
70,804 KB |
testcase_04 | AC | 362 ms
71,736 KB |
testcase_05 | AC | 352 ms
70,324 KB |
testcase_06 | AC | 554 ms
70,456 KB |
testcase_07 | AC | 458 ms
72,904 KB |
testcase_08 | AC | 436 ms
72,336 KB |
testcase_09 | AC | 583 ms
71,536 KB |
testcase_10 | AC | 566 ms
72,636 KB |
testcase_11 | AC | 574 ms
72,584 KB |
testcase_12 | AC | 424 ms
71,140 KB |
testcase_13 | AC | 536 ms
71,532 KB |
testcase_14 | AC | 537 ms
72,452 KB |
testcase_15 | AC | 565 ms
73,280 KB |
testcase_16 | AC | 613 ms
73,568 KB |
ソースコード
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 tmp = go("R"); if (tmp == 0) { continue; } int tmpx = x + dx[(d + i + 1) % 4]; int tmpy = y + dy[(d + i + 1) % 4]; int tmpd = (d + i + 1) % 4; if (!used[tmpx][tmpy]) { go("F"); dfs(tmpx, tmpy, tmpd); go("B"); } } } 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); } } }