結果

問題 No.232 めぐるはめぐる (2)
ユーザー 古寺いろは古寺いろは
提出日時 2016-02-28 23:01:12
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 645 ms / 1,000 ms
コード長 2,573 bytes
コンパイル時間 3,799 ms
コンパイル使用メモリ 107,180 KB
実行使用メモリ 22,932 KB
最終ジャッジ日時 2023-10-12 13:45:23
合計ジャッジ時間 9,609 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 641 ms
18,820 KB
testcase_01 AC 639 ms
22,932 KB
testcase_02 AC 640 ms
18,924 KB
testcase_03 AC 645 ms
18,988 KB
testcase_04 AC 56 ms
20,764 KB
testcase_05 AC 56 ms
20,776 KB
testcase_06 AC 57 ms
22,820 KB
testcase_07 AC 57 ms
22,744 KB
testcase_08 AC 471 ms
22,692 KB
testcase_09 AC 56 ms
20,692 KB
testcase_10 AC 59 ms
20,788 KB
testcase_11 AC 57 ms
20,676 KB
testcase_12 AC 57 ms
20,632 KB
testcase_13 AC 57 ms
20,680 KB
testcase_14 AC 58 ms
20,800 KB
testcase_15 AC 57 ms
20,748 KB
testcase_16 AC 56 ms
20,812 KB
testcase_17 AC 57 ms
20,684 KB
testcase_18 AC 63 ms
18,732 KB
testcase_19 AC 58 ms
20,744 KB
testcase_20 AC 57 ms
22,816 KB
testcase_21 AC 57 ms
20,684 KB
testcase_22 AC 58 ms
20,656 KB
testcase_23 AC 56 ms
20,864 KB
testcase_24 AC 57 ms
20,780 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.IO;

class Meguru
{

    public Meguru() { }
    public static int Main()
    {
        new Meguru().calc();
        return 0;
    }

    Scanner cin;

    void calc()
    {
        cin = new Scanner();
        int T = cin.nextInt();
        int A = cin.nextInt();
        int B = cin.nextInt();
        if (T < Math.Max(A, B))
        {
            Console.WriteLine("NO");
            return;
        }

        string s = "^>v<";

        int[] movey = new int[T];
        int[] movex = new int[T];
        for (int i = 0; i < T; i++)
        {
            if (A > 0) { movey[i] = 0; A--; }
            else if (i < T - 1) { movey[i] = 2; A++; }
            else { movey[i] = -1; }

            if (B > 0) { movex[i] = 1; B--; }
            else if (i < T - 1) { movex[i] = 3; B++; }
            else { movex[i] = -1; }
        }

        bool flag = true;
        for (int i = T - 1; i >= 0; i--)
        {
            if (movex[i] == -1 && movey[i] == -1)
            {
                for (int j = 0; j < i; j++)
                {
                    if (movex[j] != -1 && movex[j] != -1)
                    {
                        swap(ref movex[j], ref movex[i]);
                        break;
                    }
                }
                if (movex[i] == -1 && movey[i] == -1) flag = false;
            }
        }
        if (!flag) Console.WriteLine("NO");
        else
        {
            Console.WriteLine("YES");
            for (int i = 0; i < T; i++)
            {
                if (movey[i] != -1) Console.Write(s[movey[i]]);
                if (movex[i] != -1) Console.Write(s[movex[i]]);
                Console.WriteLine();
            }
        }

    }

    //swap
    void swap<T>(ref T a, ref T b)
    {
        T c = a;
        a = b;
        b = c;
    } 

}






class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return next();
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }

}
0