結果
問題 |
No.240 ナイト散歩
|
ユーザー |
![]() |
提出日時 | 2018-11-14 22:00:35 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 449 bytes |
コンパイル時間 | 1,723 ms |
コンパイル使用メモリ | 166,804 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-12-24 13:51:38 |
合計ジャッジ時間 | 3,050 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; ll x, y; int dx[] = { 2,1,-1,-2,-2,-1,1,2 }; int dy[] = { 1,2,2,1,-1,-2,-2,-1 }; bool f=false; bool dfs(int sx, int sy, int depth) { if (sx == x && sy == y) { return true; } if (depth == 3) { return false; } for (int i = 0; i < 8; i++) { f |= dfs(sx+dx[i],sy+dy[i],depth+1); } return f; } int main() { cin >> x >> y; cout << (dfs(0,0,0)?"YES":"NO") << endl; }