#P3616. 富金森林公园

    ID: 2424 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>线段树树状数组离散化概率论,统计洛谷月赛

富金森林公园

Description

In Boai’s Fujin Forest Park, there is a long Fujin mountain range made up of giant rocks lined up and numbered from 11 to NN. Each rock has an elevation. The mountain range lies in a basin that can hold water, and the water has its own elevation. All rocks strictly lower than this water elevation will be submerged and hidden beneath the surface.

Due to crustal movements, rock elevations may change at any time, with a single rock taking on a new elevation. Of course, the water level may also change at any time.

Because of this geological wonder, many tourists visit. As a visitor, uim can tell you the current water level elevation, and you must tell him how many contiguous visible parts there are on the mountain range. (Rocks exactly at the water level are also considered visible.)

Input Format

The first line contains two integers NN and MM, representing NN rocks and MM queries.

The next line contains NN integers AiA_i representing the initial elevation of each rock.

Then follow MM lines. Each line has two or three numbers:

  • If the first number is 1, it is followed by a single BjB_j, representing the water level elevation.
  • If the first number is 2, it is followed by two integers CjC_j and DjD_j, meaning the elevation of rock numbered CjC_j becomes DjD_j.

Output Format

For each 1 query, output a single integer: the number of contiguous visible segments.

5 4
8 6 3 5 4
1 5
2 4 1
1 5
1 3
2
1
2

Hint

  • For 10%10\% of the testdata, N,M2000N, M \le 2000.
  • Additionally, for 30%30\% of the testdata, there are only 1 queries.
  • For 100%100\% of the testdata, 1N,M2000001 \le N, M \le 200000, 1Ai,Bj,Dj1091 \le A_i, B_j, D_j \le 10^9, and there is at least one 1 query.

Translated by ChatGPT 5