結果

問題 No.232 めぐるはめぐる (2)
ユーザー omuomu
提出日時 2015-07-13 09:08:24
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 8 ms / 1,000 ms
コード長 1,429 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 76,316 KB
実行使用メモリ 4,352 KB
最終ジャッジ日時 2023-10-12 13:38:25
合計ジャッジ時間 2,541 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 8 ms
4,352 KB
testcase_01 AC 8 ms
4,348 KB
testcase_02 AC 8 ms
4,348 KB
testcase_03 AC 8 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,352 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 6 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,348 KB
testcase_14 AC 1 ms
4,352 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 1 ms
4,348 KB
testcase_18 AC 1 ms
4,352 KB
testcase_19 AC 2 ms
4,348 KB
testcase_20 AC 2 ms
4,348 KB
testcase_21 AC 1 ms
4,352 KB
testcase_22 AC 2 ms
4,348 KB
testcase_23 AC 1 ms
4,348 KB
testcase_24 AC 2 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <functional>
#include <sstream>
#include <queue>
#include <set>

using namespace std;

#define For(i,a,b) for(int i = (a);i < (b);i++)
#define rep(i,n) For(i,0,n)

const int dx[8] = { 1, 0, -1, 0, 1, 1, -1, -1 }, dy[8] = { 0, -1, 0, 1, -1, 1, -1, 1 };
string dc[8] = { ">", "v", "<", "^", ">^", ">v", "<^", "<v" };

typedef pair<int, int> P;

int main(){

	int t, a, b;
	cin >> t >> a >> b;

	vector<char> ud, rl;

	if (a > t || b > t){
		cout << "NO" << endl; return 0;
	}

	bool fa = false;
	rep(i, a){
		ud.push_back('^');
	}
	int ta = t - a;
	if (ta % 2){
		fa = true;			
		ta--;
	}
	{
		rep(i, ta / 2){
			ud.push_back('^');
			ud.push_back('v');
		}
	}


	bool fb = false;
	rep(i, b){
		rl.push_back('>');
	}
	int tb = t - b;
	if (tb % 2){
		fb = true;
		tb--;
	}
	{
		rep(i, tb / 2){
			rl.push_back('>');
			rl.push_back('<');
		}
	}

	stringstream ss;

	while (t != max(rl.size(), ud.size())){

		if (!rl.size() && !ud.size()){
			cout << "NO" << endl; return 0;
		}

		if (rl.size() && rl.size() < ud.size()){
			ss << rl[rl.size() - 1] << endl;
			rl.pop_back();
		}
		else
		if(ud.size()){
			ss << ud[ud.size() - 1] << endl;
			ud.pop_back();
		}
		t--;
	}

	cout << "YES" << endl;
	
	rep(i, t){
		if (i < rl.size()){
			ss << rl[i];
		}
		if (i < ud.size()){
			ss << ud[i];
		}
		ss << endl;
	}

	cout << ss.str();

	return 0;
}
0