結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
ldsyb
|
| 提出日時 | 2016-03-18 01:13:56 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 434 bytes |
| コンパイル時間 | 498 ms |
| コンパイル使用メモリ | 55,276 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-07 21:22:54 |
| 合計ジャッジ時間 | 1,370 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
using namespace std;
int x,y;
bool dfs(int a,int b,int n){
if(n > 3) return false;
else if(x == a && y == b) return true;
else{
int dx[] = {-2,-2,-1,-1,1,1,2,2},dy[] = {-1,1,-2,2,-2,2,-1,1};
bool check = false;
for(int i = 0;i < 8;i++) check |= dfs(a + dx[i],b + dy[i],n + 1);
return check;
}
}
int main(){
cin >> x >> y;
cout << (dfs(0,0,0) ? "YES" : "NO") << endl;
}
ldsyb