結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2016-08-23 21:43:33 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,115 bytes |
コンパイル時間 | 952 ms |
コンパイル使用メモリ | 95,568 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 21:29:12 |
合計ジャッジ時間 | 2,015 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream>#include <queue>#include <map>#include <list>#include <vector>#include <string>#include <stack>#include <limits>#include <cassert>#include <fstream>#include <cstring>#include <cmath>#include <bitset>#include <iomanip>#include <algorithm>#include <functional>#include <cstdio>#include <ciso646>using namespace std;#define FOR(i,a,b) for (int i=(a);i<(b);i++)#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)#define REP(i,n) for (int i=0;i<(n);i++)#define RREP(i,n) for (int i=(n)-1;i>=0;i--)#define inf 0x3f3f3f3f#define INF INT_MAX/3#define PB push_back#define MP make_pair#define ALL(a) (a).begin(),(a).end()#define SET(a,c) memset(a,c,sizeof a)#define CLR(a) memset(a,0,sizeof a)#define pii pair<int,int>#define pcc pair<char,char>#define pic pair<int,char>#define pci pair<char,int>#define VS vector<string>#define VI vector<int>#define DEBUG(x) cout<<#x<<": "<<x<<endl#define MIN(a,b) (a>b?b:a)#define MAX(a,b) (a>b?a:b)#define pi 2*acos(0.0)#define INFILE() freopen("in0.txt","r",stdin)#define OUTFILE()freopen("out0.txt","w",stdout)#define in scanf#define out printf#define ll long long#define ull unsigned long long#define eps 1e-14#define FST first#define SEC secondint dx[] = { -2,-2,-1,-1,1,1,2,2 };int dy[] = { -1, 1, -2, 2, -2, 2, -1, 1 };int field[21][21] = {};void dfs(ll x,ll y,int depth) {if (depth >= 3) return;field[x][y] = true;for (int i = 0; i < 8; ++i) {dfs(x + dx[i], y + dy[i], depth + 1);}}int main() {int X, Y; cin >> X >> Y;if (abs(X) >= 10 or abs(Y) >= 10) {cout << "NO" << endl;return 0;}memset(field, -1, sizeof(field));field[10][10] = 3;queue<pii> q;q.push({ 10,10 });while (not q.empty()) {auto p = q.front(); q.pop();int x = p.first, y = p.second;if (field[y][x] == 0) continue;for (int i = 0; i < 8; ++i) {int xx = x + dx[i], yy = y + dy[i];if (field[yy][xx] == -1 or field[yy][xx] < field[y][x]-1) {field[yy][xx] = field[y][x] - 1;q.push({ xx ,yy });}}}cout << (field[Y+10][X+10] != -1 ? "YES" : "NO") << endl;;return 0;}