結果
問題 | No.240 ナイト散歩 |
ユーザー | btk |
提出日時 | 2015-07-10 22:54:24 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 517 bytes |
コンパイル時間 | 695 ms |
コンパイル使用メモリ | 64,988 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-07 20:51:05 |
合計ジャッジ時間 | 1,438 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include<iostream>#include<queue>using namespace std;typedef long long LL;const int dir[] = { -2, 1, 2, 1, -2, -1, 2, -1, -2 };struct p{ LL t, x, y; };int main(void){LL x,y;cin >> x >> y;queue<p> que;que.push(p{ 0, 0, 0 });while (que.empty() == false){p v = que.front(); que.pop();if (v.x == x&&v.y == y){cout << "YES" << endl; return 0;}if (v.t == 3)continue;for (int i = 0; i < 8; i++)que.push(p{ v.t + 1, v.x + dir[i], v.y + dir[i + 1] });}cout << "NO" << endl;return(0);}