結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
👑 |
| 提出日時 | 2020-01-29 19:31:50 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 648 bytes |
| コンパイル時間 | 764 ms |
| コンパイル使用メモリ | 83,288 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-16 01:59:25 |
| 合計ジャッジ時間 | 1,571 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <iostream>
#include <vector>
#include <queue>
#include <set>
using namespace std;
typedef pair<int,int> P;
struct dta{
int nw;
int x;
int y;
};
P pos[8] = {{-2,-1},{-2,1},{-1,-2},{-1,2},{1,-2},{1,2},{2,-1},{2,1}};
int main(){
set<P> A;
queue<dta> Z;
Z.push({0,0,0});
while(!Z.empty()){
dta K = Z.front();Z.pop();
A.insert({K.x,K.y});
if(K.nw == 3){
continue;
}
for(auto x:pos){
Z.push({K.nw+1,K.x+x.first,K.y+x.second});
}
}
int x,y;cin>>x>>y;
if(A.find({x,y}) != A.end())cout << "YES" << endl;
else cout << "NO" << endl;
}