結果

問題 No.232 めぐるはめぐる (2)
ユーザー airisairis
提出日時 2015-06-27 00:14:14
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 2,059 bytes
コンパイル時間 699 ms
コンパイル使用メモリ 81,112 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-22 02:43:27
合計ジャッジ時間 3,982 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 129 ms
4,376 KB
testcase_02 AC 127 ms
4,376 KB
testcase_03 AC 130 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 91 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 2 ms
4,376 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 2 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 2 ms
4,376 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; // ゴール一歩手前

// (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