結果
問題 | No.331 CodeRunnerでやれ |
ユーザー | Tsuneo Yoshioka |
提出日時 | 2015-12-24 00:50:16 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 306 ms / 5,000 ms |
コード長 | 1,824 bytes |
コンパイル時間 | 538 ms |
コンパイル使用メモリ | 67,932 KB |
実行使用メモリ | 24,324 KB |
平均クエリ数 | 346.24 |
最終ジャッジ日時 | 2023-09-23 22:42:46 |
合計ジャッジ時間 | 6,105 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 141 ms
23,520 KB |
testcase_01 | AC | 128 ms
23,376 KB |
testcase_02 | AC | 167 ms
23,548 KB |
testcase_03 | AC | 176 ms
23,512 KB |
testcase_04 | AC | 176 ms
24,264 KB |
testcase_05 | AC | 175 ms
23,556 KB |
testcase_06 | AC | 167 ms
24,180 KB |
testcase_07 | AC | 259 ms
23,368 KB |
testcase_08 | AC | 239 ms
24,232 KB |
testcase_09 | AC | 230 ms
24,256 KB |
testcase_10 | AC | 210 ms
23,356 KB |
testcase_11 | AC | 213 ms
24,324 KB |
testcase_12 | AC | 251 ms
24,192 KB |
testcase_13 | AC | 261 ms
23,628 KB |
testcase_14 | AC | 276 ms
24,192 KB |
testcase_15 | AC | 209 ms
23,788 KB |
testcase_16 | AC | 306 ms
23,380 KB |
ソースコード
#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; } } } }