#P16915. [JLCPC 2026] 洛克王国世界

    ID: 19233 远端评测题 2000ms 1024MiB 尝试: 0 已通过: 0 显示难度提高 上传者: 标签>模拟线段树二分吉林O2优化2026省赛/邀请赛

[JLCPC 2026] 洛克王国世界

Problem Description

tarjen has been playing Roco Kingdom recently, and he wants to catch some shiny sprites.

During the process of farming shiny sprites, tarjen first needs to keep catching normal sprites. Catching normal sprites can accumulate the contamination progress of a shiny pool. When the contamination progress reaches the requirement, a contaminated sprite of the corresponding pool will spawn on the map. After defeating a contaminated sprite, there is a chance to encounter a shiny sprite.

However, the number of contaminated sprites on the map is limited. If too many contaminated sprites spawn, old contaminated sprites will be pushed out by new ones.

Meanwhile, the game has a guaranteed (pity) mechanism for spawning shiny sprites. Each shiny pool has an independent pity counter. Each time you defeat a contaminated sprite of the current pool, the pity counter of that pool increases by one. When the pity counter of a pool reaches 8080, then after defeating a contaminated sprite this time, you will definitely encounter a shiny sprite.

The detailed rules are as follows.

There are nn types of normal sprites, AA families, and BB elements. The ii-th type of normal sprite belongs to family fai\mathit{fa}_i and has element eli\mathit{el}_i.

There are two kinds of shiny pools in the game:

  • Family pool FxF_x: the shiny pool of the xx-th family.
  • Element pool ExE_x: the shiny pool of the xx-th element.

Each shiny pool PP maintains four values:

  • progressP\mathsf{progress}_P: contamination progress, initially 00.
  • pityP\mathsf{pity}_P: pity counter, initially 00.
  • needP\mathsf{need}_P: the number of normal catches required to spawn one contaminated sprite (a given constant).
  • luckP\mathsf{luck}_P: the luck threshold (a given constant).

At most mm contaminated sprites can exist on the map at the same time. All contaminated sprites are arranged into a queue from earliest spawn time to latest. If the number exceeds mm, keep removing the front contaminated sprites until the number is at most mm. A contaminated sprite pushed out due to the map capacity is not considered defeated, and it will not affect the pity counter of any pool.

There are qq operations, each is one of the following two types:

  • Normal catch C T x c

    This means tarjen catches the xx-th type of normal sprite consecutively cc times, and counts these cc catches into one kind of shiny pool. If T=FT = F, they are counted into the family pool FfaxF_{\mathit{fa}_x}; if T=ET = E, they are counted into the element pool EelxE_{el_x}.

    Let the pool counted in this catch be PP. Set progressP+=c\mathsf{progress}_P \mathrel{+}= c. Then, whenever progressP≥needP\mathsf{progress}_P \ge \mathsf{need}_P, spawn one contaminated sprite belonging to pool PP, and set progressP−=needP\mathsf{progress}_P \mathrel{-}= \mathsf{need}_P.

    Note that one normal catch operation may spawn multiple contaminated sprites.

    Append the contaminated sprites spawned in this operation to the back of the queue in order; if the number exceeds mm, remove contaminated sprites from the front.

  • Defeat a contaminated sprite B k r

    This means tarjen chooses to challenge the kk-th contaminated sprite on the current map from oldest to newest.

    If the number of contaminated sprites on the current map is less than kk, output MISS, and this operation does not change any state.

    Otherwise, suppose this contaminated sprite belongs to pool PP. Remove it from the map, and set pityP+=1\mathsf{pity}_P \mathrel{+}= 1.

    Then perform the shiny check. Each pool PP has a luck threshold luckP\mathsf{luck}_P. If r≤luckPr \le \mathsf{luck}_P or pityP=80\mathsf{pity}_P = 80, then a shiny is encountered this time, and set pityP=0\mathsf{pity}_P = 0; otherwise, the pity counter is not reset. See the output section for the exact output format.

Input Format

The first line contains five integers n,A,B,m,qn, A, B, m, q(1≤n,A,B,m,q≤2×105\boldsymbol{1 \le n, A, B, m, q \le 2 \times 10^5}), representing the number of normal sprite types, the number of families, the number of elements, the maximum number of contaminated sprites that can exist on the map at the same time, and the number of operations.

The next nn lines each contain two integers fai,eli\mathit{fa}_i, \mathit{el}_i (1≤fai≤A1 \le \mathit{fa}_i \le A, 1≤eli≤B1 \le \mathit{el}_i \le B).

The next line contains AA integers needF1,…,needFA\mathsf{need}_{F_1}, \ldots, \mathsf{need}_{F_A} (1≤needFi≤1091 \le \mathsf{need}_{F_i} \le 10^9).

The next line contains BB integers needE1,…,needEB\mathsf{need}_{E_1}, \ldots, \mathsf{need}_{E_B} (1≤needEi≤1091 \le \mathsf{need}_{E_i} \le 10^9).

The next line contains AA integers luckF1,…,luckFA\mathsf{luck}_{F_1}, \ldots, \mathsf{luck}_{F_A} (0≤luckFi≤1090 \le \mathsf{luck}_{F_i} \le 10^9).

The next line contains BB integers luckE1,…,luckEB\mathsf{luck}_{E_1}, \ldots, \mathsf{luck}_{E_B} (0≤luckEi≤1090 \le \mathsf{luck}_{E_i} \le 10^9).

The next qq lines each describe an operation. The format is C T x c (T∈{F,E}\boldsymbol{T \in \{F, E\}}, 1≤x≤n\boldsymbol{1 \le x \le n}, 1≤c≤1018\boldsymbol{1 \le c \le 10^{18}}) or B k r (1≤k≤1018\boldsymbol{1 \le k \le 10^{18}}, 1≤r≤109\boldsymbol{1 \le r \le 10^9}).

Output Format

For each B operation, output one line:

  • If there are fewer than kk contaminated sprites on the map, output MISS.
  • Otherwise, if a shiny is encountered, output SHINY F x or SHINY E x.
  • Otherwise, if no shiny is encountered, output NORMAL F x p or NORMAL E x p, where xx is the index of the corresponding shiny pool, and pp is the current pity counter of that pool.
5 2 2 5 10
1 2
1 1
2 2
1 1
2 2
2 2
2 3
40 5
4 41
C E 5 9
C E 4 5
B 2 608984673
B 4 918347739
B 4 37535012
C E 5 7
B 1 712704464
C F 4 7
B 3 270899745
B 5 363752455
NORMAL E 2 1
NORMAL E 1 1
MISS
NORMAL E 2 2
NORMAL F 1 1
MISS
3 2 1 3 8
1 1
1 1
2 1
2 3
2
0 5
10
C F 1 2
C E 2 4
B 2 50
C F 3 6
B 3 3
B 5 1
C F 1 2
B 3 100
NORMAL E 1 1
SHINY F 2
MISS
NORMAL F 1 1

Hint

For sample 2, we use F1\mathit{F1} to denote a contaminated sprite of pool F 1F\ 1, and E1\mathit{E1} to denote a contaminated sprite of pool E 1E\ 1.

  • After the first two catch operations, the contaminated sprites on the map are [F1,E1,E1][\mathit{F1}, \mathit{E1}, \mathit{E1}].
  • Execute B 2 50: defeat the 2nd one (E1\mathit{E1}). Since 50>luckE1=1050 > \mathsf{luck}_{E1} = 10 and pityE1=1≠80\mathsf{pity}_{E1} = 1 \ne 80, output NORMAL E 1 1.
  • Then catch the 3rd type of sprite and count it into the family pool, spawning 22 F2\mathit{F2}. The map capacity is 33, so after the old ones are pushed out it becomes [E1,F2,F2][\mathit{E1}, \mathit{F2}, \mathit{F2}].
  • Execute B 3 3: defeat the 3rd one (F2\mathit{F2}). Since 3≤luckF2=53 \le \mathsf{luck}_{F2} = 5, a shiny is encountered, output SHINY F 2.
  • Execute B 5 1: there are fewer than 55 on the current map, output MISS.
  • The last defeated one is F1\mathit{F1}, no shiny is encountered, output NORMAL F 1 1.

Translated by ChatGPT 5