結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
kyo1
|
| 提出日時 | 2020-09-04 11:55:23 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 26 ms / 2,000 ms |
| コード長 | 741 bytes |
| コンパイル時間 | 2,109 ms |
| コンパイル使用メモリ | 195,688 KB |
| 最終ジャッジ日時 | 2025-01-14 04:25:43 |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int X, Y;
cin >> X >> Y;
function<bool(int, int, int)> rec = [&](int x, int y, int d) {
if (d == 3) return X == x && Y == y;
bool res = X == x && Y == y;
res = res | rec(x - 2, y - 1, d + 1);
res = res | rec(x - 2, y + 1, d + 1);
res = res | rec(x - 1, y - 2, d + 1);
res = res | rec(x - 1, y + 2, d + 1);
res = res | rec(x + 1, y - 2, d + 1);
res = res | rec(x + 1, y + 2, d + 1);
res = res | rec(x + 2, y - 1, d + 1);
res = res | rec(x + 2, y + 1, d + 1);
return res;
};
if (rec(0, 0, 0)) {
cout << "YES" << '\n';
} else {
cout << "NO" << '\n';
}
return 0;
}
kyo1