結果

問題 No.240 ナイト散歩
ユーザー prog470prog470
提出日時 2015-07-11 14:27:57
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 951 bytes
コンパイル時間 482 ms
コンパイル使用メモリ 63,076 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-22 11:07:02
合計ジャッジ時間 1,700 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 WA -
testcase_19 AC 2 ms
4,376 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 1 ms
4,376 KB
testcase_30 AC 2 ms
4,380 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    
    int X, Y;
    
    cin>>X>>Y;

    int dx[8] = {-1,1,2,2,1,-1,-2,-2};
    int dy[8] = {2,2,1,-1,-2,-2,-1,1};
    
    int nowx, nowy, n=0;

    queue<int> queuex;
    queue<int> queuey;
    queuex.push(0);queuey.push(0);
    
    int nextx, nexty;
    
    if(X==0 && Y==0){
    	cout<<"YES"<<endl;
      	return 0;
    }
    
    while(1){
        
        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];
            if(nextx == X && nexty ==Y){
            	cout<<"YES"<<endl;
            	return 0;
        	}
            queuex.push(nextx);
            queuey.push(nexty);
        }
        n++;
        
    }
    
    return 0;
}
0