結果

問題 No.331 CodeRunnerでやれ
ユーザー tkzw_21
提出日時 2016-02-25 16:03:22
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 396 ms / 5,000 ms
コード長 878 bytes
コンパイル時間 1,340 ms
コンパイル使用メモリ 161,164 KB
実行使用メモリ 25,484 KB
平均クエリ数 775.88
最終ジャッジ日時 2024-07-16 22:57:36
合計ジャッジ時間 7,735 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 16
権限があれば一括ダウンロードができます

ソースコード

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;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0