結果

問題 No.240 ナイト散歩
ユーザー kpinkcatkpinkcat
提出日時 2023-11-08 17:57:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,012 bytes
コンパイル時間 1,540 ms
コンパイル使用メモリ 119,764 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2023-11-08 17:57:34
合計ジャッジ時間 2,878 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 2 ms
6,676 KB
testcase_19 AC 2 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 2 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 AC 2 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 2 ms
6,676 KB
testcase_28 AC 2 ms
6,676 KB
testcase_29 AC 2 ms
6,676 KB
testcase_30 AC 2 ms
6,676 KB
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0