結果

問題 No.240 ナイト散歩
ユーザー prog470prog470
提出日時 2015-07-11 00:10:32
言語 C++11
(gcc 13.3.0)
結果
RE  
実行時間 -
コード長 933 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 64,728 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-08 02:26:34
合計ジャッジ時間 6,573 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 RE * 3
other RE * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <queue>
using namespace std;

int main() {
    
    int X, Y;
    
    cin>>X>>Y;
    
    int grid[13][13] = {0};
    grid[6][6] = 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=6, nowy=6, n=0;

    queue<int> queuex;
    queue<int> queuey;
    
    int nextx, nexty;
    
    while(1){
        
        if(grid[Y+6][X+6] == 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++){
            nextx = nowx + dx[i];
            nexty = nowy + dy[i];
            grid[nexty][nextx] = 1;
            queuex.push(nextx);
            queuey.push(nexty);
        }
        n++;
        
    }
    
    
    return 0;
}
0