結果

問題 No.232 めぐるはめぐる (2)
ユーザー btkbtk
提出日時 2015-06-26 23:00:12
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,298 bytes
コンパイル時間 965 ms
コンパイル使用メモリ 91,004 KB
実行使用メモリ 7,000 KB
最終ジャッジ日時 2023-09-22 01:27:23
合計ジャッジ時間 3,040 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<fstream>
#include<sstream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<algorithm>
#include<utility>
#include<complex>
#include<functional>
using namespace std;


#define input_init stringstream ss; string strtoken, token; istringstream is
#define input_line  getline(cin, strtoken);is.str(strtoken);is.clear(istringstream::goodbit)
#define input_token(num) ss.str(""); ss.clear(stringstream::goodbit); getline(is, token, ','); ss << token; ss >> num


int main(void){
	int T,A,B;
	cin >> T >> A >> B;
	vector<string> res(T);
	vector<pair<int, int>> xy(T+1);
	xy[T].first = A;
	xy[T].second = B;
	for (int i = T-1; i >= 0; i--){
		if (abs(xy[i + 1].first) > abs(xy[i + 1].second)){
			if (abs(i+1 - xy[i + 1].first) & 1){
				if (xy[i + 1].second >= 0){
					res[i] += ">";
					xy[i].second = xy[i + 1].second - 1;
				}
				else {
					res[i] += "<";
					xy[i].second = xy[i + 1].second + 1;
				}
				xy[i].first = xy[i + 1].first;
			}
			else{
				if (xy[i + 1].first >= 0){
					res[i] += "^";
					xy[i].first = xy[i + 1].first -1;
				}
				else {
					res[i] += "v";
					xy[i].first = xy[i + 1].first + 1;
				}

				if (xy[i + 1].second >= 0){
					res[i] += ">";
					xy[i].second = xy[i + 1].second - 1;
				}
				else {
					res[i] += "<";
					xy[i].second = xy[i + 1].second + 1;
				}

			}
		}
		else{
			if (abs(i + 1 - xy[i + 1].second) & 1){
				if (xy[i + 1].first >= 0){
					res[i] += "^";
					xy[i].first = xy[i + 1].first - 1;
				}
				else {
					res[i] += "v";
					xy[i].first = xy[i + 1].first + 1;
				}
				xy[i].second = xy[i + 1].second;
			}
			else{
				if (xy[i + 1].second >= 0){
					res[i] += ">";
					xy[i].second = xy[i + 1].second - 1;
				}
				else {
					res[i] += "<";
					xy[i].second = xy[i + 1].second + 1;
				}

				if (xy[i + 1].first >= 0){
					res[i] += "^";
					xy[i].first = xy[i + 1].first - 1;
				}
				else {
					res[i] += "v";
					xy[i].first = xy[i + 1].first + 1;
				}

			}
		}
	}
	if (xy[0].first == 0 && xy[0].second == 0){
		cout << "YES" << endl;
		for (int i = T - 1; i >= 0; i--)cout << res[i] << endl;
	}
	else cout << "NO" << endl;
	return(0);
}
0