結果
| 問題 |
No.240 ナイト散歩
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-01-03 13:48:17 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 972 bytes |
| コンパイル時間 | 760 ms |
| コンパイル使用メモリ | 89,308 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-23 21:38:16 |
| 合計ジャッジ時間 | 2,078 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
int dx[8] = {-2, -2, -1, -1, 1, 1, 2, 2};
int dy[8] = {-1, 1, -2, 2, -2, 2, -1, 1}; // 移動方向
//入力
ll gx, gy;
bool dfs(ll sx, ll sy, int count)
{
if (sx == gx && sy == gy)
return true;
if (count >= 3)
return false;
for (int i = 0; i < 8; i++)
{
//printf("%lld %lld\n", sx + dx[i], sy + dy[i]);
if (dfs(sx + dx[i], sy + dy[i], count + 1))
return true;
}
return false;
}
void solve()
{
if (dfs(0, 0, 0))
printf("YES\n");
else
printf("NO\n");
}
int main()
{
cin >> gx >> gy;
solve();
}