結果

問題 No.232 めぐるはめぐる (2)
ユーザー GrenacheGrenache
提出日時 2015-06-27 09:08:20
言語 Java21
(openjdk 21)
結果
AC  
実行時間 231 ms / 1,000 ms
コード長 2,627 bytes
コンパイル時間 3,390 ms
コンパイル使用メモリ 75,108 KB
実行使用メモリ 57,160 KB
最終ジャッジ日時 2023-10-12 13:35:56
合計ジャッジ時間 8,503 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 231 ms
56,428 KB
testcase_01 AC 224 ms
56,984 KB
testcase_02 AC 230 ms
56,852 KB
testcase_03 AC 214 ms
57,160 KB
testcase_04 AC 122 ms
56,072 KB
testcase_05 AC 122 ms
55,888 KB
testcase_06 AC 121 ms
55,940 KB
testcase_07 AC 123 ms
56,288 KB
testcase_08 AC 222 ms
56,468 KB
testcase_09 AC 121 ms
55,588 KB
testcase_10 AC 122 ms
55,764 KB
testcase_11 AC 121 ms
55,964 KB
testcase_12 AC 121 ms
55,860 KB
testcase_13 AC 121 ms
55,652 KB
testcase_14 AC 119 ms
56,300 KB
testcase_15 AC 120 ms
55,868 KB
testcase_16 AC 121 ms
56,004 KB
testcase_17 AC 121 ms
55,960 KB
testcase_18 AC 134 ms
55,956 KB
testcase_19 AC 123 ms
56,276 KB
testcase_20 AC 121 ms
55,492 KB
testcase_21 AC 122 ms
55,948 KB
testcase_22 AC 120 ms
55,860 KB
testcase_23 AC 120 ms
55,712 KB
testcase_24 AC 123 ms
55,856 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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


public class Main_yukicoder232 {

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

        int t = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();

        int d = Math.max(a, b);
        if (t >= d && (d != 0 || t != 1)) {
        	pr.println("YES");
            int x = 0;
            int y = 0;
        	for (int i = 0; i < t; i++) {
        		d = Math.max(Math.abs(b - x), Math.abs(a - y));
        		
        		if (d % 2 == (t - i) % 2) {
        			if (a - y > 0 && b - x > 0) {
    					pr.println("^>");
    					x++;
    					y++;
        			} else if (a - y > 0 && b - x == 0) {
    					pr.println("^");
    					y++;
        			} else if (a - y > 0 && b - x < 0) {
    					pr.println("^<");
    					y++;
    					x--;
        			} else if (a - y == 0 && b - x > 0) {
    					pr.println(">");
    					x++;
        			} else if (a - y == 0 && b - x == 0) {
    					pr.println(">");
    					x++;
        			} else if (a - y == 0 && b - x < 0) {
    					pr.println("<");
    					x--;
        			} else if (a - y < 0 && b - x > 0) {
    					pr.println("v>");
    					x++;
    					y--;
        			} else if (a - y < 0 && b - x == 0) {
    					pr.println("v");
    					y--;
        			} else if (a - y < 0 && b - x < 0) {
    					pr.println("v<");
    					y--;
    					x--;
        			}
        		} else {
        			if (a - y > 0 && b - x > 0) {
    					pr.println(">");
    					x++;
        			} else if (a - y > 0 && b - x == 0) {
    					pr.println("^>");
    					x++;
    					y++;
        			} else if (a - y > 0 && b - x < 0) {
    					pr.println("^");
    					y++;
        			} else if (a - y == 0 && b - x > 0) {
    					pr.println("^>");
    					y++;
    					x++;
        			} else if (a - y == 0 && b - x == 0) {
    					pr.println(">");
    					x++;
        			} else if (a - y == 0 && b - x < 0) {
    					pr.println("v<");
    					y--;
    					x--;
        			} else if (a - y < 0 && b - x > 0) {
    					pr.println(">");
    					x++;
        			} else if (a - y < 0 && b - x == 0) {
    					pr.println("v>");
    					x++;
    					y--;
        			} else if (a - y < 0 && b - x < 0) {
    					pr.println("v");
    					y--;
        			}
        		}
        	}
        } else {
        	pr.println("NO");
        }
        
        sc.close();
        pr.close();
    }

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