結果
問題 | No.240 ナイト散歩 |
ユーザー | prog470 |
提出日時 | 2015-07-10 23:57:59 |
言語 | C++11 (gcc 11.4.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 910 bytes |
コンパイル時間 | 628 ms |
コンパイル使用メモリ | 63,160 KB |
実行使用メモリ | 4,500 KB |
最終ジャッジ日時 | 2023-09-22 10:27:24 |
合計ジャッジ時間 | 11,440 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 | AC | 2 ms
4,380 KB |
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 | - |
testcase_17 | TLE | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
testcase_21 | -- | - |
testcase_22 | -- | - |
testcase_23 | -- | - |
testcase_24 | -- | - |
testcase_25 | -- | - |
testcase_26 | -- | - |
testcase_27 | -- | - |
testcase_28 | -- | - |
testcase_29 | -- | - |
testcase_30 | -- | - |
testcase_31 | -- | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
ソースコード
#include <iostream> #include <queue> using namespace std; int main() { int X, Y; cin>>X>>Y; int grid[20][20] = {0}; grid[0][0] = 1; int dx[8] = {-1,1,2,2,1,-1,-2,-2}; int dy[8] = {2,2,1,-1,-2,-2,-1,1}; int nowx=0, nowy=0, n=0; queue<int> queuex; queue<int> queuey; while(1){ if(grid[Y][X] == 1){ cout<<"YES"<<endl; return 0; } if(n == 3){ cout<<"NO"<<endl; return 0; } nowx = queuex.front(); nowy = queuey.front(); queuex.pop(); queuey.pop(); for(int i=0 ; i<8 ; i++){ int nextx = nowx + dx[i]; int nexty = nowy + dy[i]; grid[nexty][nextx] = 1; queuex.push(nextx); queuey.push(nexty); } n++; } return 0; }