結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
|
| 提出日時 | 2016-11-20 15:18:48 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 573 bytes |
| コンパイル時間 | 1,612 ms |
| コンパイル使用メモリ | 176,400 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-07 21:31:49 |
| 合計ジャッジ時間 | 2,527 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
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 };
signed main(){
int X, Y; cin >> X >> Y;
queue< tuple< int, int, int > > que;
que.emplace( 0, 0, 0 );
while( not que.empty() ){
int t, x, y; tie( t, x, y ) = que.front(); que.pop();
if( x == X and y == Y )
cout << "YES" << endl,
exit( 0 );
if( t == 3 ) continue;
for( int di = 0; di < 8; ++di )
que.emplace( t + 1, x + dx[ di ], y + dy[ di ] );
}
cout << "NO" << endl;
return 0;
}