結果
| 問題 | No.240 ナイト散歩 |
| コンテスト | |
| ユーザー |
fumi6328
|
| 提出日時 | 2018-10-07 23:06:13 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 486 bytes |
| コンパイル時間 | 1,380 ms |
| コンパイル使用メモリ | 167,032 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-10-12 14:21:20 |
| 合計ジャッジ時間 | 2,548 ms |
|
ジャッジサーバーID (参考情報) |
judge / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int x,y;
int dx[] = {-2,-2,-1,-1,1,1,2,2};
int dy[] = {-1,1,-2,2,-2,2,-1,1};
bool flag = false;
int dfs(int nx,int ny,int n)
{
if(n > 3) return 0;
if(nx == x && ny == y) flag = true;
else{
for(int i = 0; i < 8; i++){
dfs(nx+dx[i],ny+dy[i],n+1);
}
}
return flag;
}
int main()
{
cin >> x >> y;
cout << (dfs(0,0,0) ? "YES" : "NO") << endl;
return 0;
}
fumi6328