#P11101. Round Experience and Level Queries

    ID: 13159 Type: Default 1000ms 256MiB

Round Experience and Level Queries

Round Experience and Level Queries

Problem Statement: You are given a game simulation with N players. The game consists of rounds. In round r (starting from 1), each player i (1 ≤ i ≤ N) gains an experience of \[ E_{i,r} = i \times r \] Thus, after k rounds, player i's total experience is \[ E_{i} = i \times \frac{k(k+1)}{2} \] The level of a player is defined as \[ L = \left\lfloor \frac{E}{10} \right\rfloor \] You will be given Q queries. Each query is one of the following three types:

  1. Type 1: Given an integer k, output the number of distinct levels among all players after k rounds.
  2. Type 2: Given an integer k, output the total experience added to all players after k rounds.
  3. Type 3: Given integers k and i, output the total experience of player i after k rounds.

Note: The game simulation works as follows:

  • All players are numbered from 1 to N.
  • In each round r, player i gains experience equal to i * r.
  • The total experience added in the first k rounds for player i is i * (k(k+1)/2).
  • The total experience added to all players in the first k rounds is \[ \left(\frac{k(k+1)}{2}\right) \times \left(\frac{N(N+1)}{2}\right). \]
  • The level of a player is computed by dividing his total experience by 10 and taking the floor value.

inputFormat

The first line contains two integers N and Q representing the number of players and the number of queries respectively.

Each of the next Q lines contains a query in one of the following formats:

  • For a query of type 1: 1 k
  • For a query of type 2: 2 k
  • For a query of type 3: 3 k i (where 1 ≤ i ≤ N)

outputFormat

For each query, output the corresponding answer on a new line.

sample

5 3
1 3
2 3
3 3 4
4

90 24

</p>