結果
| 問題 | 
                            No.240 ナイト散歩
                             | 
                    
| コンテスト | |
| ユーザー | 
                             482ET
                         | 
                    
| 提出日時 | 2018-05-14 19:28:58 | 
| 言語 | C++11(廃止可能性あり)  (gcc 13.3.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 2 ms / 2,000 ms | 
| コード長 | 717 bytes | 
| コンパイル時間 | 1,316 ms | 
| コンパイル使用メモリ | 163,032 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-28 11:49:11 | 
| 合計ジャッジ時間 | 2,519 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 4 | 
| other | AC * 30 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long x,y;
    cin>>x>>y;
    queue<array<long long,3>> q;
    q.emplace(array<long long,3>{0,0,0});
    while(!q.empty()){
        auto tmp=q.front();
        q.pop();
        //cout<<tmp[0]<<" "<<tmp[1]<<" "<<tmp[2]<<endl;
        if(tmp[0]==x&&tmp[1]==y){
            cout<<"YES"<<endl;
            return 0;
        }
        if(tmp[2]<3){
            for(auto p:array<int,4>{-2,-1,1,2}){
                for(auto pp:array<int,2>{2/p,-2/p}){
                    q.emplace(array<long long,3>{tmp[0]+p,tmp[1]+pp,tmp[2]+1});
                }
            }
        }
    }
    cout<<"NO"<<endl;
    return 0;
    
    
}
            
            
            
        
            
482ET