結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2017-09-18 05:56:32 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 489 bytes |
コンパイル時間 | 659 ms |
コンパイル使用メモリ | 74,368 KB |
実行使用メモリ | 5,248 KB |
最終ジャッジ日時 | 2024-11-08 02:18:07 |
合計ジャッジ時間 | 1,715 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
コンパイルメッセージ
main.cpp:6:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 6 | main() | ^~~~
ソースコード
#include<iostream> #include<queue> using namespace std; queue<pair<int,int> >P[5]; int dx[]={-2,-2,-1,-1,1,1,2,2},dy[]={-1,1,-2,2,-2,2,-1,1}; main() { int X,Y;cin>>X>>Y; P[0].push(make_pair(0,0)); for(int i=0;i<4;i++) { while(!P[i].empty()) { int x=P[i].front().first,y=P[i].front().second; P[i].pop(); if(x==X&&y==Y) { cout<<"YES"<<endl; return 0; } for(int r=0;r<8;r++) { P[i+1].push(make_pair(x+dx[r],y+dy[r])); } } } cout<<"NO"<<endl; }