結果

問題 No.232 めぐるはめぐる (2)
ユーザー airisairis
提出日時 2015-06-27 13:00:08
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 127 ms / 1,000 ms
コード長 1,831 bytes
コンパイル時間 562 ms
コンパイル使用メモリ 76,360 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-12 13:35:28
合計ジャッジ時間 2,507 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <numeric>
#include <bitset>
#include <complex>
#define rep(x, to) for (int x = 0; x < (to); x++)
#define REP(x, a, to) for (int x = (a); x < (to); x++)
#define foreach(itr, x) for (typeof((x).begin()) itr = (x).begin(); itr != (x).end(); itr++)
#define EPS (1e-14)

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef complex<double> Complex;
typedef vector< vector<int> > Mat;

int t, a, b;
int y, x; //現在地

int main() {
	cin >> t >> a >> b;
	if (a == 0 && b == 0 && t == 1) {
		cout << "NO" << endl;
		return 0;
	}
	if (max(a, b) > t) {
		cout << "NO" << endl;
		return 0;
	} 
	cout << "YES" << endl;
	int r = t - max(a, b);
	// 無駄な動きが1だけ必要なときは最小に無駄に動く
	if (r == 1) {
		if (min(a, b) > 0) {
			cout << "^" << endl;
			cout << ">" << endl;
			x++; y++;
		} else if (a == 0 && b > 0) {
			cout << "^>" << endl;
			cout << "v" << endl;
			x++;
		} else {
			//a > 0 && b == 0
			cout << "^>" << endl;
			cout << "<" << endl;
			y++;
		}
		t -= 2;
	}
	// ゴールまで行く
	while (a != y || b != x) {
		if (y < a && x < b) {
			cout << "^>" << endl;
			x++; y++;
		} else if (y < a) {
			cout << "^" << endl;
			y++;
		} else {
			// x < b;
			cout << ">" << endl;
			x++;
		}
		t--;
	}
	// 残り無駄な動きでゴール位置で帳尻あわせ
	// tは1以外の値になっている
	while (t > 0) {
		if (t % 2 == 1) {
			cout << ">" << endl;
			cout << "v" << endl;
			cout << "<^" << endl;
			t -= 3;
		} else {
			cout << ">" << endl;
			cout << "<" << endl;
			t -= 2;
		}
	}
	return 0;
}


0