結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2018-04-30 21:10:46 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 899 bytes |
コンパイル時間 | 632 ms |
コンパイル使用メモリ | 75,372 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-27 23:58:21 |
合計ジャッジ時間 | 1,845 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include<iostream>#include<queue>using namespace std;int main(){int x, y, move = 0;cin >> x >> y;pair<int, int> dst = {x, y};bool able = false;queue<pair<int, int> > points;points.push({0, 0});while(!points.empty() && move <= (8+64+512)){pair<int , int> now = points.front();points.pop();if(now == dst){able = true;break;}for(int dx = 1; dx <= 2; dx++){int dy = (dx == 1 ? 2 : 1);points.push(make_pair(now.first+dx, now.second+dy));points.push(make_pair(now.first+dx, now.second-dy));points.push(make_pair(now.first-dx, now.second+dy));points.push(make_pair(now.first-dx, now.second-dy));}move++;}if(able) cout << "YES" << endl;else cout << "NO" << endl;return 0;}