結果

問題 No.331 CodeRunnerでやれ
ユーザー fiordfiord
提出日時 2016-01-05 18:28:53
言語 C++11
(gcc 11.4.0)
結果
RE  
実行時間 -
コード長 1,111 bytes
コンパイル時間 1,377 ms
コンパイル使用メモリ 146,580 KB
実行使用メモリ 24,328 KB
平均クエリ数 7.82
最終ジャッジ日時 2023-09-23 08:43:45
合計ジャッジ時間 8,349 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int use[50][50];
//25,25位からスタート。0:未訪問,1:訪問済み,2:壁
int x=25,y=25;
int direction=0;//0:上,1:右,2:下,3:左
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
bool turn_right(){
	int d=(direction+1)%4;
	cout<<"check:"<<x+dx[d]<<","<<y+dy[d]<<":"<<use[y+dy[d]][x+dx[d]]<<endl;
	if(use[y+dy[d]][x+dx[d]]==0)	return true;
	return false;
}
int main(){
	while(true){
		use[y][x]=1;
		cout<<"direction:"<<direction<<endl;
		cout<<"condition:"<<use[y+dy[direction]][x+dx[direction]]<<endl;
		string s;	cin>>s;
		if(s=="Merry Christmas!")	return 0;
		int n=stoi(s);
		if(n==20151224)	cout<<"F"<<endl;//これで終了
		else{
			cout<<"cur:"<<x<<","<<y<<endl;
			cout<<"wall:"<<x+dx[direction]*(n+1)<<","<<y+dy[direction]*(n+1)<<endl;
			use[y+dy[direction]*(n+1)][x+dx[direction]*(n+1)]=2;
			if(turn_right()){
				cout<<"R"<<endl;
				(direction+=1)%=4;
			}
			else if(n==0){
				cout<<"L"<<endl;
				(direction+=3)%=4;
			}
			else if(use[y+dy[direction]][x+dx[direction]]!=2){
				cout<<"F"<<endl;
				x+=dx[direction];	y+=dy[direction];
			}
		}
	}
}
0