結果
問題 |
No.240 ナイト散歩
|
ユーザー |
![]() |
提出日時 | 2017-05-07 23:37:43 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 586 bytes |
コンパイル時間 | 1,693 ms |
コンパイル使用メモリ | 172,376 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-07 21:38:55 |
合計ジャッジ時間 | 2,697 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>#define REP(i,n,N) for(int i=(n);i<(int)N;i++)#define p(s) cout<<(s)<<endl#define ck(n,a,b) ((a)<=(n)&&(n)<(b))#define F first#define S secondtypedef long long ll;using namespace std;const int inf=1e9;int dx[]={-2,-2,-1,-1,1,1,2,2};int dy[]={-1,1,-2,2,-2,2,-1,1};int main(){int gx,gy;cin>>gx>>gy;queue<pair<int,int>> q;q.push({0,0});string ans="NO";while(!q.empty()){int x=q.front().F,y=q.front().S;q.pop();if(x==gx && y==gy) ans="YES";if(x==6 && y==3) break;REP(i,0,8) q.push({x+dx[i],y+dy[i]});}p(ans);return 0;}