CF193B Xor

题目描述

### 题意翻译 给定四个长度为 $n$,下标从 $1$ 到 $n$ 的数组 $a$,$b$,$k$,$p$,保证 $p_1, p_2,\cdots, p_n$ 是 $1, 2,\cdots, n$ 的一个排列。 你要对数组 $a$ 进行恰好 $u$ 次操作,每次可以在以下两种操作中选择一种: 1. 对所有 $i = 1, 2,\cdots, n$,将 $a_i$ 修改为 $a_i \oplus b_i$。($\oplus$ 表示异或) 1. 对所有 $i = 1, 2,\cdots, n$,将 $a_i$ 修改为 $a_{p_i} + r$。 请问,$u$ 次操作之后 $\sum \limits _{i=1}^n a_i \times k_i$ 最大为多少。

输入格式

第一行三个正整数 $n, u, r$。 第二行 $n$ 个正整数表示 $a$。 第三行 $n$ 个正整数表示 $b$。 第四行 $n$ 个正整数表示 $k$。 第五行 $n$ 个正整数表示 $p$。

输出格式

只有一行,$\sum \limits _{i=1}^n a_i \times k_i$ 的最大值。 ### 数据规模 $1 \le n,u \le 30$。 $0 \le r \le 100$。 $0 \le a_i,b_i \le 10^4$。

说明/提示

In the first sample you should first apply the operation of the first type, then the operation of the second type.