結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2017-09-28 07:39:23 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 939 bytes |
コンパイル時間 | 651 ms |
コンパイル使用メモリ | 83,284 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-15 18:12:28 |
合計ジャッジ時間 | 1,664 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <iostream>#include <vector>#include <string>#include <cstring>#include <math.h>#include <cmath>#include <limits.h>#include <map>#include <set>#include <queue>#include <algorithm>#include <functional>#include <stdio.h>using namespace std;long long MOD = 1000000007;int knight[8][2] = { {2,1}, {-2,1}, {2,-1}, {-2,-1}, {1,2}, {-1,2}, {1,-2}, {-1,-2} };vector< pair<int,int> > P;void dfs( int d, int x, int y ) {P.push_back( make_pair(x,y) );if ( d == 0 ) { return; }for ( int i = 0; i < 8; i++ ) {dfs( d-1, x+knight[i][0], y+knight[i][1] );}}int main() {long long X,Y;cin >> X >> Y;dfs( 3, 0, 0 );bool ans = false;for ( int i = 0; i < P.size(); i++ ) {if ( P[i].first == X && P[i].second == Y ) { ans = true; break; }}cout << ( ans ? "YES" : "NO" ) << endl;return 0;}