結果
| 問題 |
No.240 ナイト散歩
|
| コンテスト | |
| ユーザー |
basscl_sugi
|
| 提出日時 | 2018-05-14 19:36:45 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 2,000 ms |
| コード長 | 709 bytes |
| コンパイル時間 | 1,710 ms |
| コンパイル使用メモリ | 178,436 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-28 11:49:19 |
| 合計ジャッジ時間 | 2,756 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 30 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int main(void){
const int v[8][2] = {{-2,-1},{-2,1},{-1,-2},{-1,2},{1,2},{2,-1},{2,1},{1,-2}};
queue<array<long long, 3>> que;
set<pair<long long,long long>> s;
long long x,y;
cin>>x>>y;
que.emplace(array<long long, 3>({{0,0,0}}));
while(!que.empty()){
auto tmp = que.front();que.pop();
s.insert(make_pair(tmp[0],tmp[1]));
if(tmp[2]==3) continue;
for(int i=0;i<8;i++){
que.push(array<long long, 3>({{tmp[0]+v[i][0],tmp[1]+v[i][1],tmp[2]+1}}));
}
}
if (s.find(make_pair(x,y)) == s.end()) {
cout<<"NO"<<endl;
}else{
cout<<"YES"<<endl;
}
return 0;
}
basscl_sugi