結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2017-03-12 18:45:16 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 846 bytes |
コンパイル時間 | 1,308 ms |
コンパイル使用メモリ | 158,880 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-30 00:33:08 |
合計ジャッジ時間 | 2,691 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
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 1000000007typedef 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-2,cnt+1)) {return true;}if (dfs(x-2,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+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";}}