結果
| 問題 | No.331 CodeRunnerでやれ |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-24 00:49:18 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,810 bytes |
| 記録 | |
| コンパイル時間 | 656 ms |
| コンパイル使用メモリ | 68,108 KB |
| 実行使用メモリ | 25,988 KB |
| 平均クエリ数 | 8.00 |
| 最終ジャッジ日時 | 2024-07-16 08:15:02 |
| 合計ジャッジ時間 | 4,826 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | WA * 1 |
| other | WA * 16 |
ソースコード
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
using namespace std;
int main(void){
// Here your code !
ios::sync_with_stdio(false);
string str;
vector< vector<bool> >visited(100, vector<bool>(100, false));
int cur_x = 50, cur_y = 50;
int cur_d = 0;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
vector <int> st;
while(!cin.eof()){
getline(cin, str);
cout << "str=" << str << "..." << endl;
cout << "cur_x=" << cur_x << ", cur_y=" << cur_y << ", cur_d=" << cur_d << endl;
cout << "stack: ";
for(auto d:st){
cout << d << " ";
}
cout << endl;
if(str=="Merry Christmas!"){
exit(0);
}
int i = atoi(str.c_str());
visited[cur_x][cur_y] = true;
if(i==0){
visited[cur_x + dx[cur_d]][cur_y + dy[cur_d]] = true;
}
int next_d = -1;
for(int d=0;d<4;d++){
if(! visited[cur_x + dx[d]][cur_y + dy[d]]){
next_d = d;
break;
}
}
if(next_d==-1){
int d = (st.back() + 2)%4;
if(cur_d==d){
cur_x += dx[cur_d];
cur_y += dy[cur_d];
st.pop_back();
cout << "F" << endl << flush;
}else{
cur_d=(cur_d+1)%4;
cout << "L" << endl << flush;
}
}else{
if(cur_d==next_d){
cur_x += dx[cur_d];
cur_y += dy[cur_d];
st.push_back(cur_d);
cout << "F" << endl << flush;
}else{
cur_d=(cur_d+1)%4;
cout << "L" << endl << flush;
}
}
}
}