n: switches, made of zeros and ones (a switch is off or on), and funds, the money held in each account. Then the queries in queries run in order, each made of three numbers:
- [1, l, r]: toggle every switch with index from l to r inclusive, so 0 becomes 1 and 1 becomes 0;
- [2, p, 0]: a payout, adding p to every account i whose switch is on;
- [3, 0, 0]: report the current total over all accounts.
Return the answers to the type 3 queries in the order they appear.switches=[0, 1, 1, 0], funds=[5, 0, 2, 1], queries=[[2, 10, 0], [3, 0, 0], [1, 0, 1], [2, 1, 0], [3, 0, 0]] → [28, 30]
Two switches are on, so a payout of 10 adds 20: 8 + 20 = 28. Then switches 0 and 1 flip, leaving 0 and 2 on, and a payout of 1 adds 2 more: 30.
switches=[1, 1], funds=[3, 4], queries=[[1, 0, 1], [2, 100, 0], [3, 0, 0]] → [7]
After the flip every switch is off, so the payout reaches no one and the total stays 7.
switches=[0, 1, 1, 0], funds=[5, 0, 2, 1], queries=[[2, 10, 0], [3, 0, 0], [1, 0, 1], [2, 1, 0], [3, 0, 0]]
[28, 30]
Run checks the first 3 tests in your browser. Submit checks all 70 tests on the server, hidden ones included.