結果
| 問題 |
No.240 ナイト散歩
|
| コンテスト | |
| ユーザー |
kuro
|
| 提出日時 | 2021-04-30 14:50:41 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,198 bytes |
| コンパイル時間 | 1,311 ms |
| コンパイル使用メモリ | 167,644 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 12:03:51 |
| 合計ジャッジ時間 | 2,133 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#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;
}
kuro