CF1039C.Network Safety

提高+/省选-

通过率:0%

时间限制:3.00s

内存限制:512MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The Metropolis computer network consists of nn servers, each has an encryption key in the range from 00 to 2k−12^k - 1 assigned to it. Let cic_i be the encryption key assigned to the ii-th server. Additionally, mm pairs of servers are directly connected via a data communication channel. Because of the encryption algorithms specifics, a data communication channel can only be considered safe if the two servers it connects have distinct encryption keys. The initial assignment of encryption keys is guaranteed to keep all data communication channels safe.

You have been informed that a new virus is actively spreading across the internet, and it is capable to change the encryption key of any server it infects. More specifically, the virus body contains some unknown number xx in the same aforementioned range, and when server ii is infected, its encryption key changes from cic_i to ci⊕xc_i \oplus x, where ⊕\oplus denotes the bitwise XOR operation.

Sadly, you know neither the number xx nor which servers of Metropolis are going to be infected by the dangerous virus, so you have decided to count the number of such situations in which all data communication channels remain safe. Formally speaking, you need to find the number of pairs (A,x)(A, x), where AA is some (possibly empty) subset of the set of servers and xx is some number in the range from 00 to 2k−12^k - 1, such that when all servers from the chosen subset AA and none of the others are infected by a virus containing the number xx, all data communication channels remain safe. Since this number can be quite big, you are asked to find its remainder modulo 109+710^9 + 7.

Metropolis 计算机网络由 nn 台服务器组成,每台服务器被分配一个取值范围在 00 到 2k−12^k - 1 之间的加密密钥。设第 ii 台服务器的加密密钥为 cic_i。此外,有 mm 对服务器通过数据通信信道直接相连。由于加密算法的特性,仅当一条数据通信信道所连接的两台服务器具有不同的加密密钥时,该信道才被视为安全的。初始的密钥分配保证了所有数据通信信道均是安全的。

你已获悉一种新型病毒正在互联网上迅速传播,该病毒能够修改其感染的任意服务器的加密密钥。更具体地说,病毒体内包含某个未知数 xx(同样在 00 到 2k−12^k - 1 的范围内),当服务器 ii 被感染时,其加密密钥将由 cic_i 变为 ci⊕xc_i \oplus x,其中 ⊕\oplus 表示按位异或运算。

遗憾的是,你既不知道该未知数 xx 的值,也不知道 Metropolis 网络中哪些服务器将被这种危险病毒所感染。因此,你决定统计所有可能的情形数目,使得在这些情形下,所有数据通信信道仍保持安全。形式化地讲,你需要计算满足如下条件的二元组 (A,x)(A, x) 的个数:其中 AA 是服务器集合的某个(可能为空的)子集,xx 是 00 到 2k−12^k - 1 范围内的某个整数;当且仅当 AA 中的所有服务器被携带数字 xx 的病毒所感染时,所有数据通信信道仍保持安全。由于该数目可能非常大,你只需输出其对 109+710^9 + 7 取模的结果。

输入格式

The first line of input contains three integers nn, mm and kk (1≤n≤500 0001 \leq n \leq 500\,000, 0≤m≤min⁡(n(n−1)2,500 000)0 \leq m \leq \min(\frac{n(n - 1)}{2}, 500\,000), 0≤k≤600 \leq k \leq 60) — the number of servers, the number of pairs of servers directly connected by a data communication channel, and the parameter kk, which defines the range of possible values for encryption keys.

The next line contains nn integers cic_i (0≤ci≤2k−10 \leq c_i \leq 2^k - 1), the ii-th of which is the encryption key used by the ii-th server.

The next mm lines contain two integers uiu_i and viv_i each (1≤ui,vi≤n1 \leq u_i, v_i \leq n, ui≠viu_i \ne v_i) denoting that those servers are connected by a data communication channel. It is guaranteed that each pair of servers appears in this list at most once.

输入的第一行包含三个整数 nn、mm 和 kk(1≤n≤500 0001 \leq n \leq 500\,000,0≤m≤min⁡(n(n−1)2,500 000)0 \leq m \leq \min(\frac{n(n - 1)}{2}, 500\,000),0≤k≤600 \leq k \leq 60),分别表示服务器的数量、直接通过数据通信信道相连的服务器对数,以及参数 kk(它定义了加密密钥可能取值的范围)。

第二行包含 nn 个整数 cic_i(0≤ci≤2k−10 \leq c_i \leq 2^k - 1),其中第 ii 个数表示第 ii 台服务器所使用的加密密钥。

接下来的 mm 行每行包含两个整数 uiu_i 和 viv_i(1≤ui,vi≤n1 \leq u_i, v_i \leq n,ui≠viu_i \ne v_i),表示这两台服务器之间存在一条数据通信信道。保证每对服务器在此列表中至多出现一次。

输出格式

The only output line should contain a single integer — the number of safe infections of some subset of servers by a virus with some parameter, modulo 109+710^9 + 7.

唯一的一行输出应包含一个整数——即病毒以某一参数感染某服务器子集的安全感染方案数,对 109+710^9 + 7 取模。

输入输出样例

  • 输入#1

    4 4 2
    0 1 0 1
    1 2
    2 3
    3 4
    4 1

    输出#1

    50
  • 输入#2

    4 5 3
    7 1 7 2
    1 2
    2 3
    3 4
    4 1
    2 4

    输出#2

    96

说明/提示

Consider the first example.

Possible values for the number xx contained by the virus are 00, 11, 22 and 33.

For values 00, 22 and 33 the virus can infect any subset of the set of servers, which gives us 1616 pairs for each values. A virus containing the number 11 can infect either all of the servers, or none. This gives us 16+2+16+16=5016 + 2 + 16 + 16 = 50 pairs in total.

考虑第一个例子。

病毒所含数字 xx 的可能取值为 00、11、22 和 33。

对于取值 00、22 和 33,病毒可以感染服务器集合的任意子集,每种取值对应 1616 个数对。而含数字 11 的病毒只能感染全部服务器或不感染任何服务器,因此仅对应 22 个数对。综上,总数对为 16+2+16+16=5016 + 2 + 16 + 16 = 50。

输入解题思路,AI测评打分。不知道怎么写?

首页