using S = std::array<i64, 2>;
using Function = std::pair<bool, i64>;
auto mapping = [&](Function f, S x) -> S {
if (f.first) {
return S{f.second, x[1]};
} else {
return S{x[0] + f.second * x[1], x[1]};
}
};
auto composition = [&](Function f, Function g) -> Function {
if (f.first) {
return Function{true, f.second};
} else {
return Function{false, f.second + g.second};
}
};
auto op = [&](S lhs, S rhs) -> S {
return S{std::max(lhs[0], rhs[0]), lhs[1] + rhs[1]};
};
auto e = [&]() -> S {
return S{-inf64, 0};
};
auto id = [&]() -> Function {
return Function{false, 0};
};
我这样设计的是错的,
请问如何设计?(