結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2015-07-10 22:33:30 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 856 bytes |
コンパイル時間 | 521 ms |
コンパイル使用メモリ | 58,340 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-07 20:48:40 |
合計ジャッジ時間 | 1,296 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream> #include <vector> #include <string> using namespace std; typedef long long LL; bool srch(LL gx, LL gy, LL x, LL y, int rest){ if(gx == x && gy == y) return true; if(rest <= 0) return false; if(srch(gx, gy, x + 2, y + 1, rest-1)) return true; if(srch(gx, gy, x + 2, y - 1, rest-1)) return true; if(srch(gx, gy, x - 2, y + 1, rest-1)) return true; if(srch(gx, gy, x - 2, y - 1, rest-1)) return true; if(srch(gx, gy, x + 1, y + 2, rest-1)) return true; if(srch(gx, gy, x - 1, y + 2, rest-1)) return true; if(srch(gx, gy, x + 1, y - 2, rest-1)) return true; if(srch(gx, gy, x - 1, y - 2, rest-1)) return true; return false; } int main(){ LL x, y; cin >> x >> y; if(srch(x, y, 0, 0, 3)){ cout << "YES" << endl; }else{ cout << "NO" << endl; } return 0; }