結果
| 問題 | No.240 ナイト散歩 |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-11-20 15:18:48 |
| 言語 | C++14 (gcc 15.3.0 + boost 1.92.0 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 1 ms / 2,000 ms |
| + 332µs | |
| コード長 | 573 bytes |
| 記録 | |
| コンパイル時間 | 992 ms |
| コンパイル使用メモリ | 188,144 KB |
| 実行使用メモリ | 6,528 KB |
| 最終ジャッジ日時 | 2026-09-11 17:21:00 |
| 合計ジャッジ時間 | 2,670 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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;
}