結果

問題 No.232 めぐるはめぐる (2)
ユーザー Grenache
提出日時 2015-06-27 09:08:20
言語 Java
(openjdk 23)
結果
AC  
実行時間 244 ms / 1,000 ms
コード長 2,627 bytes
コンパイル時間 3,943 ms
コンパイル使用メモリ 78,204 KB
実行使用メモリ 42,824 KB
最終ジャッジ日時 2024-09-14 12:34:18
合計ジャッジ時間 9,163 ms
ジャッジサーバーID
(参考情報)
judge1 / judge6
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

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