結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2017-09-18 11:56:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 825 ms |
コンパイル使用メモリ | 74,624 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 02:27:19 |
合計ジャッジ時間 | 1,775 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream>#include <iomanip>#include <vector>typedef unsigned long long ul;typedef signed long long ll;std::vector< ll > kx = {-2, -2, -1, -1, 1, 1, 2, 2};std::vector< ll > ky = {-1, 1, -2, 2, -2, 2, -1, 1};bool dfs(int depth, ll x, ll y, ll gx, ll gy){if (x==gx && y==gy) return true;if (depth==0) return false;for (int i = 0; i < 8; ++i) {if (dfs(depth-1, x+kx[i], y+ky[i], gx, gy)) return true;}return false;}int main(void){std::cin.tie(0);std::ios::sync_with_stdio(false);std::cout << std::fixed << std::setprecision(2);ll x, y;std::cin >> x >> y;std::cout << (dfs(3, 0, 0, x, y) ? "YES" : "NO") << std::endl;return 0;}