#K77607. Amusement Park Simulation

    ID: 34902 Type: Default 1000ms 256MiB

Amusement Park Simulation

Amusement Park Simulation

You are given an amusement park simulation problem. The park operates with a number of rides, each having an initial thrill level, and several tickets. Each ticket provides access to a set of rides. You are also given a series of queries to process.

There are two types of queries:

  • Type 1: Update a ride's thrill level. The query is of the form: \(1\ X\ Y\), which means update the thrill level of ride \(X\) to \(Y\).
  • Type 2: Query the maximum thrill level accessible with a range of tickets. The query is of the form: \(2\ L\ R\ K\). Here, tickets numbered from \(L\) to \(R\) (inclusive) are considered, and \(K\) is a given integer that does not affect the calculation. You need to compute the maximum thrill level among all rides accessible by these tickets.

The rides are numbered from \(1\) to \(N\). Each ticket specifies the rides it can access. Your task is to process all the queries in order and output the answer for each query of Type 2.

inputFormat

The input is read from standard input (stdin) and has the following format:

N M Q
T1 T2 ... TN
k1 r1 r2 ... rk1
k2 r1 r2 ... rk2
... (M lines for each ticket)
q1
q2
...
qQ

Where:

  • N is the number of rides.
  • M is the number of tickets.
  • Q is the number of queries.
  • \(T_i\) represents the thrill level of the \(i\)th ride.
  • Each ticket line begins with an integer \(k\) (the number of rides accessible with that ticket) followed by \(k\) integers representing the ride indices (1-indexed).
  • Each query is either of the form "1 X Y" to update the thrill level of ride \(X\) to \(Y\), or "2 L R K" to query the maximum thrill level accessible by tickets numbered from \(L\) to \(R\). Note that the value \(K\) in Type 2 queries should be ignored.

outputFormat

For each query of Type 2, output the maximum thrill level (from the rides accessible by the specified range of tickets) on a separate line to standard output (stdout).

## sample
5 2 3
3 5 4 2 1
3 1 2 3
2 3 5
2 1 2 100
1 3 10
2 1 2 100
5

10

</p>