結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2022-05-31 02:27:18 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 2,019 bytes |
コンパイル時間 | 958 ms |
コンパイル使用メモリ | 99,676 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 01:00:33 |
合計ジャッジ時間 | 2,010 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
// yukicodr//No.240//二次元可変配列//vector <vector <int>> mass;//vector <vector <int>> memo;//vector <int> memo;//#include "stdafx.h"#include <iostream>#include <vector>#include <list>//list#include <queue> //queue#include <set> //tree#include <map> //連想配列#include <unordered_set> //hash#include <unordered_map> //hash#include <algorithm>#include <iomanip>#include <cstring>//#include <bits/stdc++.h>using namespace std;#define FOR(x,to) for(x=0;x<to;x++)#define ZERO(a) memset(a,0,sizeof(a))#define MINUS(a) memset(a,0xff,sizeof(a))#define FMAX(a,b) ((a)>(b)?(a):(b))#define FMIN(a,b) ((a)<(b)?(a):(b))#define FCEIL(a,b) ((a)+(b)-1)/(b)typedef unsigned long long ULL;typedef signed long long SLL;//昇順int compare_up(const int * a, const int *b){if (*a > *b)return (1);else if (*a < *b)return (-1);return (0);}//降順int compare_down(const int * a, const int *b){if (*a > *b)return (-1);else if (*a < *b)return (1);return (0);}int solve(int i, ULL index_flag){return 0;}SLL dx[8] = { -2,-2,-1,-1, 1, 1, 2, 2 };SLL dy[8] = { -1, 1,-2, 2,-2, 2,-1, 1 };SLL X, Y;typedef struct COORD {SLL x;SLL y;}COORD;queue<COORD> _queue;COORD a;SLL ban[25][25];int main(){SLL k = 0;cin >> X;cin >> Y;if (abs(X) >= 10 || abs(Y) >= 10){cout << "NO" << endl;return 0;}a.x = 0;a.y = 0;ban[a.y + 10][a.x + 10] = 8;for (int j = 0; j <65; j++){for (int i = 0; i < 8; i++){COORD c;c.x =a.x+ dx[i];c.y =a.y+ dy[i];if(c.y ==0 && c.x == 0)ban[c.y + 10][c.x + 10] = 8;elseban[c.y + 10][c.x + 10] = 1;_queue.push(c); //キューに入れる}//先頭を見るa = _queue.front();//先頭を取り除く_queue.pop();}/*for (int y = 0;y<20;y++){for (int x = 0; x < 20;x++)cout << ban[y][x];cout << endl;}*/if (ban[Y+10][X+10])cout << "YES" << endl;elsecout << "NO" << endl;//getchar();return 0;}