about Lambda 表达式
  • 板块灌水区
  • 楼主封禁用户
  • 当前回复3
  • 已保存回复3
  • 发布时间2024/8/26 14:57
  • 上次更新2024/8/26 16:59:16
查看原帖
about Lambda 表达式
937222
封禁用户楼主2024/8/26 14:57

它没法递归吗?

auto dfs = [&](int x, int y) -> int {
	    if (f[x][y]) return f[x][y];
	    f[x][y] = 1;
	    for (int i = 1; i <= 4; ++ i)
	    {
	        int tx = x + dx[i];
	        int ty = y + dy[i];
	        if (tx >= 1 && tx <= n && ty >= 1 && ty <= m && mp[tx][ty] < mp[x][y])
	            f[x][y] = max(f[x][y], dfs(tx, ty) + 1);
	    }
	    return f[x][y];
	};

他要报错

27	37	C:\Users\Lenovo\Documents\a.cpp	[Error] use of 'dfs' before deduction of 'auto'
27	37	C:\Users\Lenovo\Documents\a.cpp	[Error] use of 'main()::<lambda(int, int)>::<dfs capture>' before deduction of 'auto'
27	47	C:\Users\Lenovo\Documents\a.cpp	[Error] 'dfs' cannot be used as a function
2024/8/26 14:57
加载中...