結果

問題 No.232 めぐるはめぐる (2)
ユーザー airis
提出日時 2015-06-27 00:14:14
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 2,059 bytes
コンパイル時間 590 ms
コンパイル使用メモリ 87,048 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-07 19:30:51
合計ジャッジ時間 3,050 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 12 WA * 10
権限があれば一括ダウンロードができます

ソースコード

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; // ゴール一歩手前

// (sy,sx) -> (gy, gx)にr手でぴったりいける?
// (sy,sx),(gy,gx)は隣接関係
void calc(int sy, int sx, int gy, int gx, int r) {
	if (sy + 1 == gy && sx == gx) {
		if (r % 2 == 1) {
			string s[2] = {"^","v"};
			rep(i, r) cout << s[i&1] << endl;
		} else {
			string s[2] = {"^<","v>"};
			rep(i, r - 1) cout << s[i&1] << endl;
			cout << ">^" << endl;
		}
	} else if (sy == gy && sx + 1 == gx) {
		if (r % 2 == 1) {
			string s[2] = {">","<"};
			rep(i, r) cout << s[i&1] << endl;
		} else {
			string s[2] = {">^","<v"};
			rep(i, r - 1) cout << s[i&1] << endl;
			cout << "v>" << endl;
		}
	} else {
		if (r % 2 == 1) {
			string s[2] = {"^>","v<"};
			rep(i, r) cout << s[i&1] << endl;
		} else {
			string s[2] = {"^","v"};
			rep(i, r - 1) cout << s[i&1] << endl;
			cout << ">" << endl;
		}
	}
}

int main() {
	cin >> t >> a >> b;
	if (a > b) {
		y = a - 1;
		x = b;
	} else if (a < b) {
		y = a;
		x = b - 1;
	} else {
		y = a - 1;
		x = b - 1;
	}
	if (max(a, b) > t) {
		cout << "NO" << endl;
	} else {
		cout << "YES" << endl;
		rep(i, min(y, x)) {
			cout << ">^" << endl;
		}
		if (y > x) {
			rep(i, y - x) {
				cout << "^" << endl;
			}
			calc(y, x, a, b, t - y);
		} else if (y < x) {
			rep(i, x - y) {
				cout << ">" << endl;
			}
			calc(y, x, a, b, t - x);
		} else {
			calc(y, x, a, b, t - x);
		}
	}
	return 0;
}


0