結果

問題 No.240 ナイト散歩
ユーザー siro53
提出日時 2019-01-03 13:02:22
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 908 bytes
コンパイル時間 928 ms
コンパイル使用メモリ 89,032 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-23 21:38:06
合計ジャッジ時間 2,281 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1 WA * 3
other WA * 30
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;

void dfs(ll sx, ll sy, int count)
{
    if (sx == gx && sx == gy)
    {
        printf("YES\n");
        exit(0);
    }
    if (count == 3)
        return;
    for (int i = 0; i < 8; i++)
    {
        printf("%lld %lld\n", sx + dx[i], sy + dy[i]);
        dfs(sx + dx[i], sy + dy[i], count + 1);
    }
}

void solve()
{
    dfs(0, 0, 0);
    printf("NO\n");
}

int main()
{
    cin >> gx >> gy;
    solve();
}
0