Drunk Coding

Interview

Time limit1sMemory limit256 MB

Summary
Maintain a sequence under point updates and answer range-product sign queries (+/-/0) for each test case until EOF.
Level

Medium5 of 10

Topics
Segment tree, Prefix sum, Math, Implementation
Solved
No attempts yet

Problem

It is the night before the ACM-ICPC contest. To unwind, Sanggeun heads to a nearby bar with his teammates.

To warm up for the next day's contest, they decide to play a small game.

First, Seonyeong writes down a sequence of NN integers X1,X2,…,XNX_1, X_2, \dots, X_N for Sanggeun. The game consists of KK rounds, and in each round Seonyeong issues one of the following two commands.

  • Change: Replace one value of the sequence with a new value.
  • Multiply: Seonyeong names ii and jj; Sanggeun must answer whether the product Xi×Xi+1×⋯×XjX_i \times X_{i+1} \times \dots \times X_j is positive, negative, or zero.

Every wrong answer to a multiply command costs Sanggeun a shot of soju. Luckily, Seonyeong lets him use his laptop, and Sanggeun trusts his coding skills more than his mental arithmetic.

Write a program that helps Sanggeun answer each multiply command.

Input

The input consists of several test cases, processed one after another until end of file.

The first line of each test case contains the sequence size NN and the number of rounds KK. (1≤N,K≤1051 \le N, K \le 10^5)

The second line contains the values X1,X2,…,XNX_1, X_2, \dots, X_N separated by spaces. (−100≤Xi≤100-100 \le X_i \le 100)

Each of the next KK lines contains one command, starting with the letter C or P.

  • C i V: a change command; set XiX_i to VV. (1≤i≤N1 \le i \le N, −100≤V≤100-100 \le V \le 100)
  • P i j: a multiply command; ask for the sign of Xi×⋯×XjX_i \times \dots \times X_j. (1≤i≤j≤N1 \le i \le j \le N)

Each test case contains at least one multiply command.

Output

For each test case, print the results of all its multiply commands concatenated on a single line. The ii-th character is the result of the ii-th multiply command: print + if the product is positive, - if it is negative, and 0 if it is zero.

Hint

Ballmer's Peak Theory is the (tongue-in-cheek) claim that programmers write superhuman code when their blood alcohol concentration is between 0.129% and 0.138%.

Examples1

  1. Example 1

    Input
    4 6
    -2 6 0 -1
    C 1 10
    P 1 4
    C 3 7
    P 2 2
    C 4 -5
    P 1 4
    5 9
    1 5 -2 4 3
    P 1 2
    P 1 5
    C 4 -5
    P 1 5
    P 4 5
    C 3 0
    P 1 5
    C 4 -5
    C 4 -5
    
    Expected output
    0+-
    +-+-0