CF1039C.Network Safety
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
The Metropolis computer network consists of n servers, each has an encryption key in the range from 0 to 2k−1 assigned to it. Let ci be the encryption key assigned to the i -th server. Additionally, m 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 x in the same aforementioned range, and when server i is infected, its encryption key changes from ci to ci⊕x , where ⊕ denotes the bitwise XOR operation.
Sadly, you know neither the number x 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) , where A is some (possibly empty) subset of the set of servers and x is some number in the range from 0 to 2k−1 , such that when all servers from the chosen subset A and none of the others are infected by a virus containing the number x , all data communication channels remain safe. Since this number can be quite big, you are asked to find its remainder modulo 109+7 .
输入格式
The first line of input contains three integers n , m and k ( 1≤n≤500000 , 0≤m≤min(2n(n−1),500000) , 0≤k≤60 ) — the number of servers, the number of pairs of servers directly connected by a data communication channel, and the parameter k , which defines the range of possible values for encryption keys.
The next line contains n integers ci ( 0≤ci≤2k−1 ), the i -th of which is the encryption key used by the i -th server.
The next m lines contain two integers ui and vi each ( 1≤ui,vi≤n , ui=vi ) 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.
输出格式
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+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 x contained by the virus are 0 , 1 , 2 and 3 .
For values 0 , 2 and 3 the virus can infect any subset of the set of servers, which gives us 16 pairs for each values. A virus containing the number 1 can infect either all of the servers, or none. This gives us 16+2+16+16=50 pairs in total.