結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
hotpepsi
|
| 提出日時 | 2016-09-06 00:42:26 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 745 bytes |
| コンパイル時間 | 463 ms |
| コンパイル使用メモリ | 57,464 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-07 21:29:34 |
| 合計ジャッジ時間 | 1,302 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <sstream>
using namespace std;
int vis[64][64];
void dfs(int x, int y, int d) {
vis[y][x] = d;
if (d >= 4) {
return;
}
for (int i = -2; i <= 2; ++i) {
for (int j = -2; j <= 2; ++j) {
if (i * j == 2 || i * j == -2) {
if (!vis[y + i][x + j]) {
vis[y + i][x + j] = d + 1;
}
}
}
}
for (int i = -2; i <= 2; ++i) {
for (int j = -2; j <= 2; ++j) {
if (i * j == 2 || i * j == -2) {
if (vis[y + i][x + j] == d + 1) {
dfs(x + j, y + i, d + 1);
}
}
}
}
}
int main(int argc, char *argv[]) {
dfs(32, 32, 1);
int x, y;
cin >> x >> y;
x += 32, y += 32;
string ans = x >= 0 && x < 64 && y >= 0 && y < 64 && vis[y][x] ? "YES" : "NO";
cout << ans << endl;
return 0;
}
hotpepsi