| 1 | #define BITS 15 |
| 2 | struct misof_tree { |
| 3 | int cnt[BITS][1<<BITS]; |
| 4 | misof_tree() { memset(cnt, 0, sizeof(cnt)); } |
| 5 | void insert(int x) { |
| 6 | for (int i = 0; i < BITS; cnt[i++][x]++, x >>= 1); } |
| 7 | void erase(int x) { |
| 8 | for (int i = 0; i < BITS; cnt[i++][x]--, x >>= 1); } |
| 9 | int nth(int n) { |
| 10 | int res = 0; |
| 11 | for (int i = BITS-1; i >= 0; i--) |
| 12 | if (cnt[i][res <<= 1] <= n) n -= cnt[i][res], res |= 1; |
| 13 | return res; } }; |
| 14 | // vim: cc=60 ts=2 sts=2 sw=2: |
nothing calls this directly
no outgoing calls
no test coverage detected