結果

問題 No.240 ナイト散歩
ユーザー nak3nak3
提出日時 2017-03-12 18:48:41
言語 C++11
(gcc 11.4.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 847 bytes
コンパイル時間 1,237 ms
コンパイル使用メモリ 158,204 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-04-16 19:46:42
合計ジャッジ時間 2,249 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
6,944 KB
testcase_03 WA -
testcase_04 AC 1 ms
6,944 KB
testcase_05 AC 1 ms
6,944 KB
testcase_06 WA -
testcase_07 AC 1 ms
6,944 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 1 ms
6,940 KB
testcase_20 AC 1 ms
6,944 KB
testcase_21 AC 2 ms
6,940 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,940 KB
testcase_24 AC 1 ms
6,940 KB
testcase_25 AC 1 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,944 KB
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘bool dfs(int, int, int)’:
main.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
   51 | }
      | ^

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

#define INF 2000000000
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;

int a, b;

bool dfs(int tmpx, int tmpy, int tmpcnt){
	int x = tmpx;
	int y = tmpy;
	int cnt = tmpcnt;
//	cout << x << " " << y << " " << cnt << "\n";
	if (cnt>3) {
		return false;
	}
	if (x==a && y==b) {
		return true;
	}

	if (dfs(x-2,y-1,cnt+1)) {
		return true;
	}
	if (dfs(x-2,y+1,cnt+1)) {
		return true;
	}

	if (dfs(x-1,y-2,cnt+1)) {
		return true;
	}
	if (dfs(x-1,y+2,cnt+1)) {
		return true;
	}

	if (dfs(x+1,y-2,cnt+1)) {
		return true;
	}
	if (dfs(x+1,y+2,cnt+1)) {
		return true;
	}

	if (dfs(x+2,y-1,cnt+1)) {
		return true;
	}
	if (dfs(x+2,y+1,cnt+1)) {
		return true;
	}
}


int main()
{
	cin >> a >> b;

	if (dfs(0,0,0)) {
		cout << "YES" << "\n";
	} else {
		cout << "NO" << "\n";
	}

}
0