結果
問題 | No.240 ナイト散歩 |
ユーザー |
|
提出日時 | 2020-07-11 18:39:33 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 18 ms / 2,000 ms |
コード長 | 597 bytes |
コンパイル時間 | 1,952 ms |
コンパイル使用メモリ | 198,784 KB |
最終ジャッジ日時 | 2025-01-11 19:49:54 |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 30 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) set<pair<int, int> > vis; void go(int x, int y, int d = 0) { if (d > 3) return; vis.insert({x, y}); for (int i = -2; i <= 2; i++) { for (int j = -2; j <= 2; j++) { if ((abs(i) == 2 && abs(j) == 1) || (abs(i) == 1&& abs(j) == 2)) { go(x+i, y+j, d+1); } } } } int main() { ios_base::sync_with_stdio(0); cin.tie(0); go(0, 0); int x, y; cin >> x >> y; if (vis.count({x, y})) cout << "YES" << endl; else cout << "NO" << endl; return 0; }