結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
data9824
|
| 提出日時 | 2015-08-12 13:37:02 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 582 bytes |
| コンパイル時間 | 588 ms |
| コンパイル使用メモリ | 63,984 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-07 21:02:35 |
| 合計ジャッジ時間 | 1,396 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <set>
#include <utility>
using namespace std;
const int dx[] = { -2, -2, -1, -1, 1, 1, 2, 2 };
const int dy[] = { 1, -1, 2, -2, 2, -2, 1, -1 };
set<pair<int, int> > reachables;
void step(int x, int y, int remain) {
reachables.insert(make_pair(x, y));
if (remain == 0) {
return;
}
for (int i = 0; i < 8; ++i) {
step(x + dx[i], y + dy[i], remain - 1);
}
}
int main() {
step(0, 0, 3);
int x, y;
cin >> x >> y;
bool reachable = reachables.find(make_pair(x, y)) != reachables.end();
cout << (reachable ? "YES" : "NO") << endl;
return 0;
}
data9824