結果
問題 | No.240 ナイト散歩 |
ユーザー |
![]() |
提出日時 | 2018-05-14 19:40:40 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 2,000 ms |
コード長 | 1,702 bytes |
コンパイル時間 | 2,236 ms |
コンパイル使用メモリ | 198,320 KB |
最終ジャッジ日時 | 2025-01-05 10:36:36 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h>using namespace std;int main(void){int depth = 0, count = 0;long long int X, Y;bool find = true;cin >> X >> Y;queue<complex<long long int>> que;que.push(complex<long long int> (0, 0));while(!que.empty()) {if(pow(8, depth) <= count) depth++;auto now_x = que.front().real();auto now_y = que.front().imag();//8つの場合においてアレ//1if(now_x + 1 == X && now_y + 2 == Y) {break;}else {que.push(complex<long long int> (now_x + 1, now_y + 2));count++;}//2if(now_x - 1 == X && now_y + 2 == Y) {break;}else {que.push(complex<long long int> (now_x - 1, now_y + 2));count++;}//3if(now_x - 2 == X && now_y + 1 == Y) {break;}else {que.push(complex<long long int> (now_x - 2, now_y + 1));count++;}//4if(now_x - 2 == X && now_y - 1 == Y) {break;}else {que.push(complex<long long int> (now_x - 2, now_y - 1));count++;}//5if(now_x - 1 == X && now_y - 2 == Y) {break;}else {que.push(complex<long long int> (now_x - 1, now_y - 2));count++;}//6if(now_x + 1 == X && now_y - 2 == Y) {break;}else {que.push(complex<long long int> (now_x + 1, now_y - 2));count++;}//7if(now_x + 2 == X && now_y - 1 == Y) {break;}else {que.push(complex<long long int> (now_x + 2, now_y - 1));count++;}//8if(now_x + 2 == X && now_y + 1 == Y) {break;}else {que.push(complex<long long int> (now_x + 2, now_y + 1));count++;}que.pop();if(depth > 3) {find = false;break;}}if(find) cout << "YES" << endl;else cout << "NO" << endl;}