• + 0 comments

    The solution can be found much more quickly than the editorial says due to combinatorial simplification; there is a two-line solution (that is, two lines in the query loop, one of them being the input line) that runs in O(X + Y + T) time. No Y^3 needed. A hint: https://oeis.org/A033184 I think the problem setter didn't check for an accidental identity.