QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#717136#8981. Kangaroo PuzzleKobicGendCompile Error//C++201.4kb2024-11-06 17:01:152024-11-06 17:01:15

Judging History

你现在查看的是最新测评结果

  • [2024-11-06 17:01:15]
  • 评测
  • [2024-11-06 17:01:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

const int dx[] = { 1, 0, -1, 0 };
const int dy[] = { 0, 1, 0, -1 };
const string dir = "DRUL";

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);

    int n, m;
    cin >> n >> m;

    vector<string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }

    vector<vector<int>> E(n * m);

    auto change = [&](int x, int y) {
        return x * m + y;
    };
    auto get = [&](int p) {
        return pair(p / m, p % m);
    };

    int sx = -1, sy = -1;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i][j] == '1') {
                sx = i, sy = j;
            }
        }
    }

    vector vis(n, vector<int>(m));
    string path;
    if (sx != -1) {
        auto dfs = [&](this auto&& self, int x, int y) -> void {
            //cerr << "dfs " << x << " " << y << endl;
            for (int i = 0; i < 4; i++) {
                auto [nx, ny] = pair(x + dx[i], y + dy[i]);
                if (nx < 0 || nx >= n || ny < 0 || ny >= m) continue;
                if (s[nx][ny] == '0') continue;
                if (vis[nx][ny]) continue;
                vis[nx][ny] = 1;
                path += dir[i];
                self(nx, ny);
            }
        };
        vis[sx][sy] = 1;
        dfs(sx, sy);
    }
    cout << path << endl;

    return 0;
}

詳細信息

answer.code: In function ‘int main()’:
answer.code:42:24: error: expected identifier before ‘this’
   42 |         auto dfs = [&](this auto&& self, int x, int y) -> void {
      |                        ^~~~
answer.code:42:24: error: expected ‘,’ or ‘...’ before ‘this’
answer.code: In lambda function:
answer.code:45:38: error: ‘x’ was not declared in this scope; did you mean ‘sx’?
   45 |                 auto [nx, ny] = pair(x + dx[i], y + dy[i]);
      |                                      ^
      |                                      sx
answer.code:45:49: error: ‘y’ was not declared in this scope; did you mean ‘sy’?
   45 |                 auto [nx, ny] = pair(x + dx[i], y + dy[i]);
      |                                                 ^
      |                                                 sy
answer.code:51:17: error: ‘self’ was not declared in this scope
   51 |                 self(nx, ny);
      |                 ^~~~
answer.code: In function ‘int main()’:
answer.code:55:12: error: no match for call to ‘(main()::<lambda(int)>) (int&, int&)’
   55 |         dfs(sx, sy);
      |         ~~~^~~~~~~~
answer.code:42:20: note: candidate: ‘main()::<lambda(int)>’
   42 |         auto dfs = [&](this auto&& self, int x, int y) -> void {
      |                    ^
answer.code:42:20: note:   candidate expects 1 argument, 2 provided