結果
問題 | No.240 ナイト散歩 |
ユーザー | nasadigital |
提出日時 | 2015-07-10 23:26:40 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 775 bytes |
コンパイル時間 | 598 ms |
コンパイル使用メモリ | 66,076 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 20:51:48 |
合計ジャッジ時間 | 1,523 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <cstring> #include <queue> #include <utility> using namespace std; typedef pair<int,int> ii; typedef pair<ii,int> ti; int main(int argc, const char * argv[]) { int a,b; cin>>a>>b; queue<ti> k; k.push({{0,0},0}); while(!k.empty()){ ti tr=k.front(); k.pop(); if(tr.second==4) break; if(tr.first.first==a && tr.first.second==b){ cout<<"YES"; return 0; } for(int ctr1=-2;ctr1<3;ctr1++){ for(int ctr2=-2;ctr2<3;ctr2++){ if(abs(ctr1)+abs(ctr2)==3){ k.push({{tr.first.first+ctr1,tr.first.second+ctr2},tr.second+1}); } } } } cout<<"NO"; return 0; }