fork(1) download
  1. #include <stdio.h>
  2. int N, Q, c, l, r, a[111111];
  3. int main() {
  4. scanf("%d%d", &N, &Q);
  5. for(int i = 0; i < Q; i++) {
  6. scanf("%d%d%d", &c, &l, &r);
  7. if(c == 1) {
  8. for(int j = l; j < r; j++) a[j] = a[j] ? 0 : 1;
  9. }
  10. else {
  11. int ret = 0;
  12. for(int j = l; j < r; j++) ret += a[j];
  13. printf("%d\n", ret);
  14. }
  15. }
  16. }
Success #stdin #stdout 0s 3892KB
stdin
8 4
1 3 7
2 2 5
1 2 4
2 1 6
stdout
2
3