結果
| 問題 |
No.331 CodeRunnerでやれ
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-25 22:02:22 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 657 ms / 5,000 ms |
| コード長 | 2,270 bytes |
| コンパイル時間 | 4,216 ms |
| コンパイル使用メモリ | 78,160 KB |
| 実行使用メモリ | 72,968 KB |
| 平均クエリ数 | 409.41 |
| 最終ジャッジ日時 | 2024-07-16 22:47:59 |
| 合計ジャッジ時間 | 14,795 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 16 |
ソースコード
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);
}
}
}