結果

問題 No.240 ナイト散歩
ユーザー kurokuro
提出日時 2021-04-30 14:49:22
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,198 bytes
コンパイル時間 1,581 ms
コンパイル使用メモリ 165,172 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-25 15:17:16
合計ジャッジ時間 3,346 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct Vec2D {
  Vec2D(uint64_t _x, uint64_t _y) : x(_x), y(_y) {}
  uint64_t x;
  uint64_t y;
};

bool check(const Vec2D pos, const Vec2D targ) {
  if (pos.x == targ.x && pos.y == targ.y) {
    return true;
  } else {
    return false;
  }
}

int main() {
  uint64_t X, Y;
  cin >> X >> Y;

  Vec2D moveList[8] = {Vec2D(-2, -1), Vec2D(-2, 1), Vec2D(-1, -2), Vec2D(-1, 2),
                       Vec2D(1, -2),  Vec2D(1, 2),  Vec2D(2, -1),  Vec2D(2, 1)};
  if (X == 0 && Y == 0) {
    cout << "Yes" << endl;
    return 0;
  }

  const Vec2D targ(X, Y);

  for (int i = 0; i < 8; ++i) {
    Vec2D p0 = moveList[i];
    if (check(p0, targ)) {
      cout << "Yes" << endl;
      return 0;
    }

    for (int j = 0; j < 8; ++j) {
      Vec2D p1 = p0;
      p1.x += moveList[j].x;
      p1.y += moveList[j].y;
      if (check(p1, targ)) {
        cout << "Yes" << endl;
        return 0;
      }

      for (int k = 0; k < 8; ++k) {
        Vec2D p2 = p1;
        p2.x += moveList[k].x;
        p2.y += moveList[k].y;
        if (check(p2, targ)) {
          cout << "Yes" << endl;
          return 0;
        }
      }
    }
  }

  cout << "No" << endl;
}
0