結果

問題 No.331 CodeRunnerでやれ
ユーザー E31415926E31415926
提出日時 2016-05-28 16:09:28
言語 C++11
(gcc 11.4.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,647 bytes
コンパイル時間 846 ms
コンパイル使用メモリ 52,808 KB
実行使用メモリ 92,072 KB
平均クエリ数 0.06
最終ジャッジ日時 2023-09-23 23:59:51
合計ジャッジ時間 7,797 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
23,376 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
using namespace std;
#define	UNKNOWN	0
#define	ISEMPTY	1
#define ISWALL	2
#define UP		0
#define RIGHT	1
#define DOWN	2
#define LEFT	3

int dirtbl[4][2] = { {0,-1},{1,0},{0,1},{-1,0} };

int main()
{
	//初期位置を(19,19)上向きとする
	int map[39][39]{ {0} }, x = 19, y = 19,
		dx = 0, dy = -1, n, i, xtmp, ytmp, direction = UP,
		dirtmp;
	map[19][19] = ISEMPTY;

	while (1) {
		cin >> n;
		if (cin.fail()) { return 0; }
		if (n == 20151224) {
			cout << "F" << endl << flush;
			x += dx; y += dy;
			continue;
		}
		map[x + (n + 1) * dx][y + (n + 1) * dy] = ISWALL;

		//右?
		dirtmp = (direction + 1) % 4;
		xtmp = dirtbl[dirtmp][0]; ytmp = dirtbl[dirtmp][1];
		if(map[x + xtmp][y+ytmp]==UNKNOWN){
			cout << "R" << endl << flush;
			direction = dirtmp;
			dx = xtmp; dy = ytmp;
			continue;
		}

		//左?
		dirtmp = (direction - 1) % 4;
		xtmp = dirtbl[dirtmp][0]; ytmp = dirtbl[dirtmp][1];
		if (map[x+xtmp][y+ytmp] == UNKNOWN) {
			cout << "L" << endl << flush;
			direction = dirtmp;
			dx = xtmp; dy = ytmp;
			continue;
		}

		//逆?
		dirtmp = (direction + 2) % 4;
		xtmp = dirtbl[dirtmp][0]; ytmp = dirtbl[dirtmp][1];
		if (map[x+xtmp][y+ytmp] == UNKNOWN) {
			cout << "R" << endl << flush;
			direction = (direction + 1) % 4;
			dx = dirtbl[direction][0]; dy = dirtbl[direction][1];
			continue;
		}

		//壁?
		if (map[x + dx][y + dy] == ISWALL) {
			cout << "R" << endl << flush;
			direction = (direction + 1) % 4;
			dx = dirtbl[direction][0]; dy = dirtbl[direction][1];
			continue;
		}

		//それ以外
		cout << "F" << endl << flush;
		x += dx; y += dy;
		map[x][y] = ISEMPTY;
	}
	return 0;
}
0