結果
問題 |
No.240 ナイト散歩
|
ユーザー |
|
提出日時 | 2016-05-02 14:00:31 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,090 bytes |
コンパイル時間 | 611 ms |
コンパイル使用メモリ | 67,960 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-05 02:13:38 |
合計ジャッジ時間 | 1,656 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 29 WA * 1 |
ソースコード
#include <iostream> #include <utility> #include <queue> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(0); int x, y; cin >> x >> y; pair<int, int> aimPos = make_pair(x, y); pair<int, int> knightPos(0, 0); vector<pair<int, int>> knightMove{make_pair(-2,-1), make_pair(-2,1), make_pair(-1, 2), make_pair(1,2), make_pair(2,1), make_pair(2,-1), make_pair(1,-2), make_pair(-1,-2) }; bool arrival = false; queue<pair<int, int>> q; q.push(knightPos); int count = 512; //8^3 while (1) { if (count == 0) break; count--; knightPos = q.front(); if (knightPos == aimPos) { arrival = true; break; } q.pop(); for (int i = 0; i < 8; ++i) { q.push(make_pair(knightPos.first + knightMove.at(i).first, knightPos.second + knightMove.at(i).second)); } } cout << (arrival ? "YES" : "NO") << endl; return 0; }