結果

問題 No.240 ナイト散歩
コンテスト
ユーザー Rumain831
提出日時 2026-10-21 23:46:26
言語 C++23(gcc16)
(gcc 16.2.0 + boost 1.92.0 + ACL)
コンパイル:
g++-16 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc16.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 760µs
コード長 609 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,210 ms
コンパイル使用メモリ 202,196 KB
実行使用メモリ 9,924 KB
最終ジャッジ日時 2026-10-28 17:35:57
合計ジャッジ時間 4,434 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge5_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
using namespace std;
using P = pair<int, int>;
using tu = tuple<int, int, int>;

int main(void){
  int x, y; cin >> x >> y;
  int di[9]={-2, -2, -1, -1, 1, 1, 2, 2, 0};
  int dj[9]={-1, 1, -2, 2, -2, 2, -1, 1, 0};
  set<P> co;
  auto dfs=[&](auto dfs, int step, int ni, int nj)->void {
    if(step==3){
      co.emplace(ni, nj); return;
    }
    for(int k=0; k<9; k++){
      dfs(dfs, step+1, ni+di[k], nj+dj[k]);
    }
    return;
  };
  dfs(dfs, 0, 0, 0);
  cout << (co.count(P(x, y))?"YES":"NO") << endl;
  return 0; 
}
0