結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
nak3
|
| 提出日時 | 2017-03-12 18:48:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 847 bytes |
| コンパイル時間 | 1,284 ms |
| コンパイル使用メモリ | 159,008 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-07 21:36:51 |
| 合計ジャッジ時間 | 2,328 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 WA * 1 |
| other | AC * 11 WA * 19 |
コンパイルメッセージ
main.cpp: In function ‘bool dfs(int, int, int)’:
main.cpp:51:1: warning: control reaches end of non-void function [-Wreturn-type]
51 | }
| ^
ソースコード
#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";
}
}
nak3