結果
| 問題 |
No.240 ナイト散歩
|
| ユーザー |
fal_rnd
|
| 提出日時 | 2017-01-21 01:23:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 942 bytes |
| コンパイル時間 | 1,386 ms |
| コンパイル使用メモリ | 164,488 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-10-07 21:34:21 |
| 合計ジャッジ時間 | 2,598 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 29 WA * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ull = unsigned long long int;
const char en ='\n';
const int mod=1000000007;
int main(){
cin.tie();
ios::sync_with_stdio(false);
bool field[20][20]; for(int i=0;i<20;i++) fill_n(field[i],20,false);
int dx[]{-2,-2,-1,-1,1,1,2,2};
int dy[]{-1,1,-2,2,-2,2,-1,1};
deque<pair<int,int>> d;
d.push_back(make_pair(10,10));
field[10][10]=true;
for(int i=0;i<3;i++){
int size=d.size();
for(int j=0;j<size;j++){
pair<int,int> p=d.front(),q;
d.pop_front();
for(int k=0;k<8;k++){
q=make_pair(p.first+dx[k],p.second+dy[k]);
d.push_back(q);
field[q.first][q.second]=true;
}
}
}
int x,y;
cin>>x>>y;
x+=10;
y+=10;
if(x>20||x<0||y>20||y<0){
cout<<"NO"<<en;
}else{
cout<<(field[x][y]?"YES":"NO")<<en;
}
/*
for(int i=0;i<20;i++){
for(int j=0;j<20;j++){
cout<<field[i][j]<<" ";
}
cout<<en;
}
*/
return 0;
}
fal_rnd