全部試す。
class YetAnotherIncredibleMachine { public: int countWays(vector <int> M, vector <int> L, vector <int> B) { sort(B.begin(), B.end()); const int size = M.size(); lli ret = 1; for (int i = 0; i < (int)size; ++i) { lli cnt = 0; for (int j = M[i] - L[i]; j <= M[i]; ++j) { int left = j; int right = j + L[i]; bool flg = true; for (int k = 0; k < (int)B.size(); ++k) { flg = flg && !(left <= B[k] && B[k] <= right); } cnt += flg; } ret *= cnt; ret %= mod; } return ret; } };