結果

問題 No.232 めぐるはめぐる (2)
ユーザー airisairis
提出日時 2015-06-27 12:50:37
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,831 bytes
コンパイル時間 701 ms
コンパイル使用メモリ 76,628 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 03:07:59
合計ジャッジ時間 4,233 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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