#P12014. [Ynoi April Fool's Round 2025] 牢帽

[Ynoi April Fool's Round 2025] 牢帽

Background

Problem Description

Hoshino Kana gives you an undirected graph with nn vertices. The graph initially has no edges. She also gives you integers u,vu, v and a1,a2,,ana_1, a_2, \cdots, a_n. There are qq operations of four types:

  1. 1 x y: Add an edge between xx and yy. It is guaranteed that this edge does not exist before.
  2. 2 x y: Delete the edge between xx and yy. It is guaranteed that this edge exists before.
  3. 3 x y: Modify axa_x to yy.
  4. 4 x: Suppose the graph is divided into kk connected components C1,C2,,CkC_1, C_2, \cdots, C_k. Compute i=1kjCi(aj+x)moduv\sum_{i=1}^k \prod_{j\in C_i}(a_j+x) \bmod u^v.

Input Format

The first line contains four integers n,q,u,vn, q, u, v.

The second line contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n.

The next qq lines each describe one operation.

Output Format

Output several lines. Each line contains one integer, the answer for each type 44 operation.

5 10 3 2
1 2 3 4 5
4 2
1 1 2
1 3 4
4 0
1 2 3
3 2 5
4 1
2 3 4
1 4 5
4 2
7
1
3
3

Hint

Idea: I forgot the source. Please ask the original problem setter by private message on QQ.

Sample 2

See the attachments ex_c2.in and ex_c2.ans. This sample satisfies Subtask 11.

Sample 3

See the attachments ex_c3.in and ex_c3.ans. This sample satisfies Subtask 22.

Sample 4

See the attachments ex_c4.in and ex_c4.ans. This sample satisfies Subtask 66.

Limits and Notes

This problem uses bundled tests.

For 100%100\% of the data, 1n,q1051\leq n,q\leq 10^5, 1u101\leq u\leq 10, 1v41\leq v\leq 4, 0ai<1040\leq a_i < 10^4. In type 33 operations, yy, and in type 44 operations, xx, are both non-negative integers less than 10410^4.

Subtask ID Score nn\leq qq\leq Special Property
11 2020 50005000 //
22 1010 10510^5 For all type 44 operations, x=0x=0.
33 1515 v=1v=1.
44 For all type 44 operations, xx is a multiple of uu.
55 There are no type 22 or type 33 operations.
66 2525 //

Translated by ChatGPT 5