結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
|
| 提出日時 | 2018-11-24 15:56:54 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 545 bytes |
| コンパイル時間 | 1,443 ms |
| コンパイル使用メモリ | 167,272 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-12-24 19:20:18 |
| 合計ジャッジ時間 | 2,518 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int dx[] = {-2, - 2, -1, -1, 1, 1, 2, 2}, dy[] = {-1, 1, -2, 2, - 2, 2, -1, 1};
void dfs(int a, int b, int c, long long d, long long e)
{
if(b == d && c == e) {
cout << "YES" << endl;
exit(0);
}
if(a == 3) return;
if(a <= 2) {
for(int i = 0; i < 8; i++) {
dfs(a + 1, b + dx[i], c + dy[i], d, e);
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
long long x, y; cin >> x >> y;
dfs(0, 0, 0, x, y);
cout << "NO" << endl;
return 0;
}