Learning Klingon P99729


Statement
 

pdf   zip

From now on it will be mandatory to study Klingon at the University, as it is the language of the future. Klingon’s grammar is easy to learn, but the real challenge comes when dealing with the vocabulary. Therefore, you have decided to write a simple program to help you, which has a list of pairs of English/Klingon words. The program keeps a weight (a positive number, initially equal to one) associated to each English word. Let ss be the current sum of weights. Repeatedly, the program arbitrarily chooses an integer xx in the range [0,s)[0, s), and shows you the first English word ww such that the sum of all the weights from the first word to ww is bigger than xx. After you write your Klingon translation of ww, if your answer is correct the weight of ww is decreased by one; otherwise it is increased by one. As you want to avoid weights equal to zero, when this happens the program adds one to the weight of every word. Similarly, when the smallest weight becomes two, the program substracts one from every weight.

For example, let us consider the words “yes”, “no”, “thanks” and “sir” in this order. Let us imagine that the first xx is 1, so the first ww is “no”. If you correctly answer “qhobe”, then the weights are changed to 1 0 1 1 and, after normalizing, to 2 1 2 2. Otherwise, the weights are updated to 1 2 1 1.

Input

Input consists of several cases. Every case begins with the number of words nn, followed by the number of queries qq, followed by qq queries, each one with xx and a 1 or a 0 depending on if your answer is right or wrong. Assume 1n31041 \le n \le 3 \cdot 10^4 and 1q31041 \le q \le 3 \cdot 10^4.

Output

For every case, print the final weight of every word divided by the final sum of weights, with no common factors. Print an empty line after every case.

Public test cases
  • Input

    4 1
    1 0
    
    4 1
    1 1
    
    4 2
    1 0
    4 1
    

    Output

    1/5
    2/5
    1/5
    1/5
    
    2/7
    1/7
    2/7
    2/7
    
    1/4
    3/8
    1/4
    1/8
    
    
  • Information
    Author
    Albert Graells
    Language
    English
    Official solutions
    C++
    User solutions
    C++