結果
問題 |
No.240 ナイト散歩
|
ユーザー |
![]() |
提出日時 | 2016-04-15 02:17:40 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 776 bytes |
コンパイル時間 | 680 ms |
コンパイル使用メモリ | 75,008 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-10-04 09:16:57 |
合計ジャッジ時間 | 7,077 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 WA * 1 RE * 1 |
other | AC * 5 WA * 8 RE * 17 |
ソースコード
#include <iostream> #include <queue> #include <vector> #define pii pair<int,int> using namespace std; int dx[]={-2, -2, -1, -1, 1, 1, 2, 2}; int dy[]={-1, 1, -2, 2, -2, 2, -1, 1}; int main(void){ int X,Y; cin>>X>>Y; unsigned long long P[X+1][Y+1]; for(int i=0;i<=X;i++){ for(int j=0;j<=Y;j++) P[i][j]=0; } queue<pii> q; q.push(pii(X,Y)); while(!q.empty()){ pii p=q.front(); q.pop(); int x=p.first,y=p.second; for(int i=0;i<8;i++){ int nx=x+dx[i],ny=y+dy[i]; if(nx<0 || ny<0 || nx>X || ny>Y) continue; if(!P[nx][ny]) continue; q.push(pii(nx,ny)); P[nx][ny]=P[x][y]+1; } } if(P[X][Y]<=3) cout<<"YES"<<endl; else cout<<"NO"<<endl; }