uery(int l, int r, int pos, int x, int y) { if (x <= l && y >= r) { sum |= node[pos].col; return; } if (node[pos].flag) { sum |= node[pos].col; return; } //push(pos); int m = l + r >> 1; if (x <= m) query(l, m, lson(pos), x, y); if (y > m) query(m+1, r, rson(pos), x, y); } } tree; void cal() { int ans = 0; int flag = 1; while (sum) { ans++; if (sum & 1) { if (flag) { printf("%d", ans); flag = 0; } else printf(" %d", ans); } sum >>= 1; } printf("\n"); } int main() { int n, m, t; while (scanf("%d%d", &n, &m) != EOF && n+m) { tree.build(1, n, 1); char op[3]; int a, b, c; while (m--) { scanf("%s", op); if (op[0] == 'P') { scanf("%d%d%d", &a, &b, &c); if (a > b) swap(a, b); tree.modify(1, n, 1, a, b, 1<<(c-1)); } else { scanf("%d%d", &a, &b); if (a > b) swap(a, b); sum = 0; tree.query(1, n, 1, a, b); cal(); } } } return 0; }
|