結果

問題 No.331 CodeRunnerでやれ
ユーザー tkzw_21tkzw_21
提出日時 2016-02-25 16:03:22
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 425 ms / 5,000 ms
コード長 878 bytes
コンパイル時間 1,154 ms
コンパイル使用メモリ 145,020 KB
実行使用メモリ 24,384 KB
平均クエリ数 775.88
最終ジャッジ日時 2023-09-23 23:12:25
合計ジャッジ時間 8,201 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
23,424 KB
testcase_01 AC 162 ms
23,364 KB
testcase_02 AC 195 ms
23,380 KB
testcase_03 AC 425 ms
23,644 KB
testcase_04 AC 217 ms
24,024 KB
testcase_05 AC 222 ms
23,532 KB
testcase_06 AC 303 ms
23,784 KB
testcase_07 AC 356 ms
24,384 KB
testcase_08 AC 296 ms
23,788 KB
testcase_09 AC 347 ms
23,596 KB
testcase_10 AC 311 ms
24,304 KB
testcase_11 AC 386 ms
23,644 KB
testcase_12 AC 328 ms
24,280 KB
testcase_13 AC 312 ms
23,544 KB
testcase_14 AC 389 ms
23,664 KB
testcase_15 AC 359 ms
24,040 KB
testcase_16 AC 371 ms
23,344 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int command(char c){
	cout << c << endl;
	string s;cin >> s;
	if( s == "Merry" ){
		cin >> s;
		exit(0);
	}
	
	int n = stoi(s);
	return n;
}

int m[100][100];
void dfs(int x,int y,int dir){
	if( m[x][y] == 1 )return;
	m[x][y] = 1;
	//cerr << x << " " << y << " " << dir << endl;
	
	for(int i=0;i<4;i++){
		int n = command('L');
		if( n == 0 )continue;
		int ndir = dir+i+1;
		if( ndir%4 == 0 ){
			command('F');
			dfs( x+1, y, ndir);
			command('B');
		}else if( ndir%4 == 1 ){
			command('F');
			dfs( x, y+1, ndir);
			command('B');
		}else if( ndir%4 == 2 ){
			command('F');
			dfs( x-1, y, ndir);
			command('B');
		}else if( ndir%4 == 3 ){
			command('F');
			dfs( x, y-1, ndir);
			command('B');
		}
	}
}

int main(void){
	memset(m,-1,sizeof(m));
	string s;
	cin >> s;
	int sx = 50, sy = 50;
	dfs( sx, sy, 0);
	return 0;
}
0