結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
|
| 提出日時 | 2018-06-10 14:46:07 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 596 bytes |
| コンパイル時間 | 1,362 ms |
| コンパイル使用メモリ | 159,324 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-06-30 13:16:57 |
| 合計ジャッジ時間 | 2,361 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int X, Y, ans;
int knight[8][2] = {{-2,-1}, {-2,+1}, {-1,-2}, {-1,+2},
{+1,-2}, {+1,+2}, {+2,-1}, {+2,+1}};
void recursive(int x, int y, int n) {
if(X == x && Y == y) ans = 1;
if(n == 3) return;
for(int i = 0; i < 8; i++) {
recursive(x + knight[i][0], y + knight[i][1], n + 1);
}
}
int main() {
#ifdef DEBUG
std::ifstream in("/home/share/inputf.in");
std::cin.rdbuf(in.rdbuf());
#endif
cin >> X >> Y;
recursive(0, 0, 0);
cout << (ans ? "YES" : "NO") << endl;
return 0;
}