結果

問題 No.232 めぐるはめぐる (2)
ユーザー data9824
提出日時 2015-08-12 12:02:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 133 ms / 1,000 ms
コード長 1,024 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 58,332 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-09-14 12:38:42
合計ジャッジ時間 2,295 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 22
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>

using namespace std;

int main() {
	int t, a, b;
	cin >> t >> a >> b;
	int chebyshev = max(a, b);
	if (t < chebyshev) {
		cout << "NO" << endl;
		return 0;
	}
	if (a == 0 && b == 0 && t == 1) {
		cout << "NO" << endl;
		return 0;
	}
	cout << "YES" << endl;
	int remain = t;
	int y = 0, x = 0;
	if ((remain - chebyshev) % 2 == 1) {
		if (a == 0 && b == 0) {
			cout << ">" << endl << "^" << endl << "<v" << endl;
			remain -= 3;
		} else if (a > 0 && b > 0) {
			cout << ">" << endl << "^" << endl;
			++y;
			++x;
			remain -= 2;
		} else if (a > 0) {
			cout << ">^" << endl << "<" << endl;
			++y;
			remain -= 2;
		} else {
			cout << ">^" << endl << "v" << endl;
			++x;
			remain -= 2;
		}
	}
	for (; y < a && x < b; ++y, ++x) {
		cout << ">^" << endl;
		--remain;
	}
	for (; y < a; ++y) {
		cout << "^" << endl;
		--remain;
	}
	for (; x < b; ++x) {
		cout << ">" << endl;
		--remain;
	}
	for (; remain > 0; remain -= 2) {
		cout << ">" << endl << "<" << endl;
	}
	return 0;
}
0