結果

問題 No.331 CodeRunnerでやれ
ユーザー 37zigen37zigen
提出日時 2016-05-28 13:42:53
言語 Java21
(openjdk 21)
結果
RE  
実行時間 -
コード長 913 bytes
コンパイル時間 3,538 ms
コンパイル使用メモリ 78,260 KB
実行使用メモリ 73,984 KB
平均クエリ数 33.88
最終ジャッジ日時 2023-09-23 10:42:00
合計ジャッジ時間 9,739 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 284 ms
71,880 KB
testcase_01 AC 299 ms
72,080 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		new Main().solve();
	}
	void solve(){
		Scanner sc=new Scanner(System.in);
		//F,B,L,R
		int[][] map=new int[200][200];
		int x=50;int y=50;
		int[] dx={1,0,-1,0};
		int[] dy={0,1,0,-1};
		int d=0;
		while(true){
			int r=(int)(Math.random()*4);
			if(r==0){
				if(map[y+dy[d%4]][x+dx[d%4]]!=-1)
					System.out.println("F");
			}else if(r==1){
				if(map[y+dy[(d+2)%4]][x+dx[(d+2)%4]]!=-1)
					System.out.println("B");
			}else if(r==2){
				System.out.println("L");
				d++;
			}else if(r==3){
				System.out.println("R");
				d--;
			}
			String s=sc.nextLine();
			if(s.equals("-1")){
				map[y+dy[d%4]][x+dx[d%4]]=-1;
			}else if(r==0){
				y=y+dy[d%4];
				x=x+dx[d%4];
			}else if(r==1){
				y=y+dy[(d+2)%4];
				x=x+dx[(d+2)%4];
			}
			if(s.equals("Merry Christmas!")){
				return;
			}
		}
	}
}
0