結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2023-11-08 17:57:30 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,012 bytes |
コンパイル時間 | 1,283 ms |
コンパイル使用メモリ | 117,968 KB |
最終ジャッジ日時 | 2025-02-17 20:08:44 |
ジャッジサーバーID (参考情報) |
judge2 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include<iostream>#include<iomanip>#include<string>#include<algorithm>#include<vector>#include<set>#include<list>#include<queue>#include<math.h>#include<bitset>using ll = long long;using namespace std;int main(){int x, y;cin >> x >> y;set<vector<int>> st;deque<vector<int>> dq;dq.push_back({0, 0, 0});st.insert({0, 0});vector<int> dx{2, 2, 1, -1, -2, -2, -1, 1}, dy{1, -1, -2, -2, -1, 1, 2, 2};while (!dq.empty()){int tx, ty, tt, nx, ny;vector<int> vt = dq.front();tx = vt[0], ty = vt[1], tt = vt[2];dq.pop_front();if (tt == 3) continue;tt++;for (int i = 0; i < 8; i++){nx = tx + dx[i];ny = ty + dy[i];st.insert({nx, ny});dq.push_back({nx, ny, tt});}}for (auto tmp : st){if (tmp.front() == x && tmp.back() == y) {cout << "YES" << endl;return 0;}}cout << "NO" << endl;}