結果
| 問題 | No.232 めぐるはめぐる (2) |
| コンテスト | |
| ユーザー |
古寺いろは
|
| 提出日時 | 2016-02-28 23:01:12 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 594 ms / 1,000 ms |
| コード長 | 2,573 bytes |
| 記録 | |
| コンパイル時間 | 2,540 ms |
| コンパイル使用メモリ | 106,240 KB |
| 実行使用メモリ | 18,048 KB |
| 最終ジャッジ日時 | 2024-09-14 12:42:10 |
| 合計ジャッジ時間 | 5,911 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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());
}
}
古寺いろは