結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2017-06-17 21:02:17 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 859 bytes |
コンパイル時間 | 729 ms |
コンパイル使用メモリ | 79,248 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-10-07 21:39:29 |
合計ジャッジ時間 | 1,796 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include<cstdio>#include <iostream>#include<algorithm>#include<string>#include<queue>#include<vector>#include<functional>#include<cmath>#include<map>#include<stack>#include<set>#include<numeric>using namespace std;typedef long long ll;typedef pair<ll, ll> Pr;ll xx, yy;int dx[] = { -2,-2,-1,-1,1,1,2,2 };int dy[] = { -1,1,-2,2,-2,2,-1,1 };int main(){cin >> xx >> yy;bool flag = false;int cnt = 0;queue<Pr> q;q.push({ 0,0 });while (!q.empty()) {ll ddx = q.front().first;ll ddy = q.front().second;q.pop();for (int i = 0; i < 8; i++) {ll x = dx[i] + ddx;ll y = dy[i] + ddy;if (x == 6 && y == 3) {cout << "NO" << endl;flag = true;break;}if (x == xx && y == yy) {cout << "YES" << endl;flag = true;break;}q.push({ x,y });}if (flag)break;}return 0;}