結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2015-09-16 18:58:04 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 1,100 bytes |
コンパイル時間 | 727 ms |
コンパイル使用メモリ | 69,664 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-07 21:10:38 |
合計ジャッジ時間 | 1,731 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream>#include <vector>#include <algorithm>#include <cmath>#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)#define FOR(i,e) FORR(i,0,e)#define sortuniq(v) sort(v.begin(), v.end()), v.erase(unique(v.begin(),v.end()),v.end())#define dump(var) cerr << #var ": " << var << "\n"#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"typedef long long ll;typedef unsigned long long ull;const double EPS = 1e-6;const int d4[] = {0, -1, 0, 1, 0};using namespace std;const int dx[] = {-2, -2, -1, -1, 1, 1, 2, 2};const int dy[] = {-1, 1, -2, 2, -2, 2, -1, 1};vector<vector<bool>> p(20, vector<bool>(20, false));void check(int x, int y, int n) {p[10+y][10+x] = true;if (n > 0) {FOR(i, 8) {check(x+dx[i], y+dy[i], n-1);}}}int main() {cin.tie(0);ios::sync_with_stdio(false);int X, Y;cin >> X >> Y;check(0, 0, 3);if (X < -6 || 6 < X || Y < -6 || 6 < Y) {cout << "NO" << endl;}else {cout << (p[10+Y][10+X]? "YES": "NO") << endl;}return 0;}