結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2022-08-09 20:22:03 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 510 bytes |
コンパイル時間 | 1,554 ms |
コンパイル使用メモリ | 171,236 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-20 00:52:12 |
合計ジャッジ時間 | 2,824 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(){int sy, sx;cin >> sy >> sx;vector<pair<int,int>> dir = {{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}};function<bool(int,int,int)> dfs = [&](int y, int x, int d){if(y == sy && x == sx)return true;if(d == 3)return false;for(auto &&p:dir){if(dfs(y + p.first, x + p.second, d + 1))return true;}return false;};cout << (dfs(0, 0, 0) ? "YES" : "NO") << endl;}