fork download
  1. void update(int pos, int val){
  2. int id = 1, ini = 1, fim = Q, mid, idx = 0;
  3. int ids[MAXN];
  4. while(ini != fim){
  5. mid = (ini + fim) / 2;
  6. ids[idx] = id;
  7. idx++;
  8. if(pos <= mid){
  9. id *= 2;
  10. fim = mid;
  11. }else{
  12. id = id * 2 + 1;
  13. ini = mid + 1;
  14. }
  15. }
  16. tree[id] = val;
  17. idx--;
  18. while(idx >= 0){
  19. id = ids[idx--];
  20. if(tree[id * 2] == 0)
  21. tree[id] = tree[id * 2 + 1];
  22. else if(tree[id * 2 + 1] == 0)
  23. tree[id] = tree[id * 2];
  24. else
  25. tree[id] = gcd(tree[id * 2], tree[id * 2 + 1]);
  26. }
  27. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'void update(int, int)':
prog.cpp:2:32: error: 'Q' was not declared in this scope
     int id = 1, ini = 1, fim = Q, mid, idx = 0;
                                ^
prog.cpp:3:13: error: 'MAXN' was not declared in this scope
     int ids[MAXN];
             ^
prog.cpp:5:9: error: 'mid' was not declared in this scope
         mid = (ini + fim) / 2;
         ^
prog.cpp:6:9: error: 'ids' was not declared in this scope
         ids[idx] = id;
         ^
prog.cpp:6:13: error: 'idx' was not declared in this scope
         ids[idx] = id;
             ^
prog.cpp:16:5: error: 'tree' was not declared in this scope
     tree[id] = val;
     ^
prog.cpp:17:5: error: 'idx' was not declared in this scope
     idx--;
     ^
prog.cpp:19:14: error: 'ids' was not declared in this scope
         id = ids[idx--];
              ^
prog.cpp:25:58: error: 'gcd' was not declared in this scope
             tree[id] = gcd(tree[id * 2], tree[id * 2 + 1]);
                                                          ^
stdout
Standard output is empty