結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2019-12-20 23:22:30 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 625 bytes |
コンパイル時間 | 1,745 ms |
コンパイル使用メモリ | 175,180 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-07-18 01:52:43 |
合計ジャッジ時間 | 2,388 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;typedef tuple<int, int, int> TP;const int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2};const int dy[] = {-1, 1, -2, 2, -2, 2, -1, 1};int main() {int x, y;cin >> x >> y;queue<TP> que;que.emplace(0, 0, 0);while (!que.empty()) {int cx, cy, c;tie(cx, cy, c) = que.front();que.pop();for (int i = 0; i < 8; i++) {int nx = cx + dx[i];int ny = cy + dy[i];if (nx == x && ny == y) {cout << "YES" << endl;return 0;}if (c != 2) que.emplace(nx, ny, c + 1);}}cout << "NO" << endl;return 0;}