I got a Wrong Answer at AtCoder, using Recursive Lambda dfs returning void, like this.
int dfs = y_combinator(
[&](auto self, int cu, int pa = -1) -> int {
dp[cu][0] = dp[cu][1] = 1;
for(auto to: g[cu]){
if(to != pa){
self(to, cu);
dp[cu][0] *= (dp[to][0] + dp[to][1]);
dp[cu][1] *= dp[to][0];
}
}
// return 0;
}
)(0);
Using too much memory (or another point?) seemed to be the reason of WA.
https://atcoder.jp/contests/dp/submissions/31097803
But if I added return value, it resolved.
https://atcoder.jp/contests/dp/submissions/31099529
What happened in this code?