結果

問題 No.323 yuki国
ユーザー yuppe19 😺yuppe19 😺
提出日時 2015-12-16 00:28:39
言語 C++11
(gcc 11.4.0)
結果
CE  
(最新)
AC  
(最初)
実行時間 -
コード長 2,021 bytes
コンパイル時間 329 ms
コンパイル使用メモリ 51,128 KB
最終ジャッジ日時 2024-04-27 02:16:35
合計ジャッジ時間 944 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。

コンパイルメッセージ
main.cpp:10:6: error: variable or field ‘debug’ declared void
   10 | void debug(vector<T> v, const char* sep) {
      |      ^~~~~
main.cpp:10:12: error: ‘vector’ was not declared in this scope
   10 | void debug(vector<T> v, const char* sep) {
      |            ^~~~~~
main.cpp:3:1: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
    2 | #include <algorithm>
  +++ |+#include <vector>
    3 | using namespace std;
main.cpp:10:20: error: expected primary-expression before ‘>’ token
   10 | void debug(vector<T> v, const char* sep) {
      |                    ^
main.cpp:10:22: error: ‘v’ was not declared in this scope
   10 | void debug(vector<T> v, const char* sep) {
      |                      ^
main.cpp:10:25: error: expected primary-expression before ‘const’
   10 | void debug(vector<T> v, const char* sep) {
      |                         ^~~~~
main.cpp:19:24: error: variable or field ‘debug’ declared void
   19 | template<class T> void debug(vector<T> v) { debug(v, " "); }
      |                        ^~~~~
main.cpp:19:30: error: ‘vector’ was not declared in this scope
   19 | template<class T> void debug(vector<T> v) { debug(v, " "); }
      |                              ^~~~~~
main.cpp:19:30: note: ‘std::vector’ is defined in header ‘<vector>’; did you forget to ‘#include <vector>’?
main.cpp:19:38: error: expected primary-expression before ‘>’ token
   19 | template<class T> void debug(vector<T> v) { debug(v, " "); }
      |                                      ^
main.cpp:19:40: error: ‘v’ was not declared in this scope
   19 | template<class T> void debug(vector<T> v) { debug(v, " "); }
      |                                        ^
main.cpp:20:24: error: variable or field ‘debug’ declared void
   20 | template<class T> void debug(vector<vector<T>> v) { int n = v.size(); for(int i=0; i<n; i++) { debug(v[i]); } }
      |                        ^~~~

ソースコード

diff #

#include <iostream>
#include <algorithm>
using namespace std;
using i64 = long long;

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;}};

template<class T>
void debug(vector<T> v, const char* sep) {
  const int n = v.size();
  fprintf(stderr, "'");
  for(int i=0; i<n; i++) {
    if(i!=0) { fprintf(stderr, "%s", sep); }
    cerr << v[i];
  }
  fprintf(stderr, "'\n");
}
template<class T> void debug(vector<T> v) { debug(v, " "); }
template<class T> void debug(vector<vector<T>> v) { int n = v.size(); for(int i=0; i<n; i++) { debug(v[i]); } }
template<class T> void debug(vector<vector<vector<T>>> v) { int n = v.size(); for(int i=0; i<n; i++) { debug(v[i]); } }
template<class T> void debug(vector<vector<vector<vector<T>>>> v) { int n = v.size(); for(int i=0; i<n; i++) { debug(v[i]); } }
template<class T> void debug(vector<vector<vector<vector<vector<T>>>>> v) { int n = v.size(); for(int i=0; i<n; i++) { debug(v[i]); } }

int R, C;
vector<string> G;
int a, b;
int sr, sc, gr, gc;
vector<vector<vector<int>>> dp;
vector<int> dr = {0, 0, 1, -1},
            dc = {1, -1, 0, 0};

int rec(int w, int r, int c) {
  int &res = dp[r][c][w];
  if(res != -1) { return res; }
  if(w == b && r == gr && c == gc) { return res = 1; }
  res = 0;
  for(int i : range(dr.size())) {
    int nr = r + dr[i],
        nc = c + dc[i];
    if(nr < 0 || R <= nr || nc < 0 || C <= nc) { continue; }
    int nw;
    if(G[nr][nc] == '.') {
      nw = w - 1;
    } else {
      nw = w + 1;
    }
    if(nw <= 0) { continue; }
    res |= rec(nw, nr, nc);
  }
  return res;
}

int main(void) {
  scanf("%d%d%d%d%d%d%d%d", &R, &C, &a, &sr, &sc, &b, &gr, &gc);
  G.resize(R);
  dp.assign(R, vector<vector<int>>(C, vector<int>(4000, -1)));
  for(int r : range(R)) { cin >> G[r]; }
  bool ok = rec(a, sr, sc);
  puts(ok ? "Yes" : "No");
  return 0;
}
0