結果

問題 No.240 ナイト散歩
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-07-10 23:18:42
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 778 bytes
コンパイル時間 392 ms
コンパイル使用メモリ 51,120 KB
最終ジャッジ日時 2023-07-29 13:29:24
合計ジャッジ時間 826 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:8:1: error: ‘vector’ does not name a type; did you mean ‘perror’?
 vector<int> dx = {-2, -2, -1, -1,  1, 1,  2, 2},
 ^~~~~~
 perror
main.cpp:8:48: error: expected unqualified-id before ‘,’ token
 vector<int> dx = {-2, -2, -1, -1,  1, 1,  2, 2},
                                                ^
main.cpp:9:16: error: expected constructor, destructor, or type conversion before ‘=’ token
             dy = {-1,  1, -2,  2, -2, 2, -1, 1};
                ^
main.cpp: In function ‘bool nya(int, int, int)’:
main.cpp:15:21: error: ‘dx’ was not declared in this scope
   for(int i : range(dx.size())) {
                     ^~
main.cpp:15:21: note: suggested alternative: ‘x’
   for(int i : range(dx.size())) {
                     ^~
                     x
main.cpp:18:20: error: ‘ny’ was not declared in this scope
     res |= nya(nx, ny, times-1);
                    ^~
main.cpp:18:20: note: suggested alternative: ‘nx’
     res |= nya(nx, ny, times-1);
                    ^~
                    nx

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

vector<int> dx = {-2, -2, -1, -1,  1, 1,  2, 2},
            dy = {-1,  1, -2,  2, -2, 2, -1, 1};

bool nya(int x, int y, int times) {
  if(times < 0) { return false; }
  if(x == 0 && y == 0) { return true; }
  bool res = false;
  for(int i : range(dx.size())) {
    int nx = x + dx[i],
        ny = y + dy[i];
    res |= nya(nx, ny, times-1);
  }
  return res;
}

int main(void) {
  int x, y; scanf("%d%d", &x, &y);
  puts(nya(x, y, 3) ? "YES" : "NO");
  return 0;
}
0