Advertisement
Guest User

Untitled

a guest
Feb 18th, 2020
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. int main() {
  2.     int n, q;
  3.     while (cin >> n >> q) {
  4.         splay<int> t;
  5.         for (int i = 0; i < n; i++) {
  6.             int x; cin >> x;
  7.             if (x) x = x > 0 ? 1 : -1;
  8.             t.push_back(x);
  9.         }
  10.         while (q--) {
  11.             char c; cin >> c;
  12.             if (c == 'C') {
  13.                 int i, x; cin >> i >> x;
  14.                 if (x) x = x > 0 ? 1 : -1;
  15.                 t[i-1] = x;
  16.             } else {
  17.                 int a, b; cin >> a >> b;
  18.                 int val = t.query(a-1, b-1);
  19.                 if (val > 0) cout << '+';
  20.                 else if (val < 0) cout << '-';
  21.                 else cout << 0;
  22.             }
  23.         }
  24.         cout << endl;
  25.     }
  26.     return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement