結果

問題 No.232 めぐるはめぐる (2)
ユーザー ぴろずぴろず
提出日時 2015-10-08 11:39:25
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,255 bytes
コンパイル時間 2,878 ms
コンパイル使用メモリ 81,988 KB
実行使用メモリ 61,308 KB
最終ジャッジ日時 2023-09-27 08:05:58
合計ジャッジ時間 10,155 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 173 ms
58,376 KB
testcase_05 AC 109 ms
55,820 KB
testcase_06 WA -
testcase_07 AC 152 ms
58,268 KB
testcase_08 WA -
testcase_09 AC 156 ms
58,656 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 111 ms
54,172 KB
testcase_24 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

package no232;

import java.util.Scanner;

public class Main {

	static int[] dx = {1,1,0,-1,-1,-1,0,1};
	static int[] dy = {0,1,1,1,0,-1,-1,-1};
	static String[] command = {">","^>","^","<^","<","<v","v","v>"};

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int t = sc.nextInt();
		int y = sc.nextInt();
		int x = sc.nextInt();
		StringBuilder ans = new StringBuilder();
		while(t > 2) {
			StringBuilder com = new StringBuilder();
			if (x > 0) {
				com.append('>');
				x--;
			}else if(x < 0) {
				com.append('<');
				x++;
			}
			if (y > 0) {
				com.append('^');
				y--;
			}else if(y < 0) {
				com.append('v');
				y++;
			}
			if (com.length() == 0) {
				com.append('<');
				x++;
			}
			ans.append(com.toString());
			ans.append('\n');
			t--;
		}
		String ans2 = solve(t,x,y);
		if (ans2 == null) {
			System.out.println("NO");
		}else{
			System.out.println("YES");
			System.out.print(ans.toString());
			System.out.println(ans2);
		}
	}

	public static String solve(int t,int x,int y) {
		if (t == 0) {
			return x == 0 && y == 0 ? "" : null;
		}
		for(int i=0;i<8;i++) {
			String s = solve(t-1,x-dx[i],y-dy[i]);
			if (s != null) {
				return command[i] + "\n" + s;
			}
		}
		return null;
	}

}
0