B. Team

Codeforces
IDCF10280B
Time4000ms
Memory64MB
Difficulty
English · Original
Formal · Original
A school has a total of $3 * n$ students, divided evenly into $A$ group, $B$ group or $C$ group, with $n$ in each group. Everyone has an ability value $v_i$, the tacit value between two students is $f (i, j) = (v_i + v_j) * (v_i plus.circle v_j) % M$, where $plus.circle$ means bitwise exclusive OR operation. As the competition coach of this school, you need to select exactly $m$ teams to participate in the $C C P C$ competition in the second half of the year. Specifically, Each team contains exactly three students, and the three students are from different groups. Let the team members from the $A, B, C$ group be $a, b, c$, then the tacit value of this team is $f (a, b) + f (a, c)$. Please find out the maximum sum of the tacit values of the $m$ teams. The input consists of multiple test cases. The first line contains an integer $T$ $(1 <= T <= 10)$ — the number of test cases. The description of the test cases follows. The first line contains three integers $n, m, M$ $(1 <= m <= n <= 200, 10 <= M <= 2000)$. Then follows three lines, each line contains $n$ integers $v_1, v_2, \\dots, v_n$ $(1 <= v_i <= 2000)$ — the ability value of each student in group $A, B$ and $C$ . For each test case, print the answer. ## Input The input consists of multiple test cases. The first line contains an integer $T$ $(1 <= T <= 10)$ — the number of test cases. The description of the test cases follows.The first line contains three integers $n, m, M$ $(1 <= m <= n <= 200, 10 <= M <= 2000)$.Then follows three lines, each line contains $n$ integers $v_1, v_2, \\dots, v_n$ $(1 <= v_i <= 2000)$ — the ability value of each student in group $A, B$ and $C$ . ## Output For each test case, print the answer. [samples]
**Definitions** Let $ n, k_1, k_2 \in \mathbb{Z} $ with $ 1 \leq n \leq 10^6 $, $ 0 \leq k_1, k_2 \leq 2^{64} - 1 $. Let $ A = (a_1, a_2, \dots, a_n) $ be a sequence of distinct positive integers generated by a deterministic function $ \texttt{gen()} $ using seeds $ k_1, k_2 $. Let $ Q \in \mathbb{Z} $ with $ 1 \leq Q \leq 5 \cdot 10^5 $ be the number of commands. **Commands** Each command is a tuple $ (\text{op}, x) $ where $ \text{op} \in \{ \texttt{F}, \texttt{D}, \texttt{C}, \texttt{R} \} $, $ x \in \mathbb{Z} $, $ 1 \leq x \leq 10^{12} - 1 $. - **F (Find)**: Find the smallest index $ i $ such that $ a_i \geq x $. Output $ a_i $ if exists, else output $ -1 $. - **D (Delete)**: Remove $ a_i $ from $ A $ where $ a_i = x $ (guaranteed to exist). - **C (Count)**: Count the number of elements $ a_i \in A $ such that $ a_i \leq x $. - **R (Reset)**: Reset $ A $ to its original state (generated by $ \texttt{gen()} $ with initial $ k_1, k_2 $). **Constraints** 1. All $ a_i $ are distinct. 2. Number of $ \texttt{R} $ commands $ \leq 10 $. **Objective** For each command $ \texttt{F} $ and $ \texttt{C} $, output the required value immediately. For $ \texttt{D} $ and $ \texttt{R} $, update the state of $ A $ accordingly.
API Response (JSON)
{
  "problem": {
    "name": "B. Team",
    "description": {
      "content": "A school has a total of $3 * n$ students, divided evenly into $A$ group, $B$ group or $C$ group, with $n$ in each group. Everyone has an ability value $v_i$, the tacit value between two students is $f",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 4000,
      "memory_limit": 65536
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF10280B"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "A school has a total of $3 * n$ students, divided evenly into $A$ group, $B$ group or $C$ group, with $n$ in each group. Everyone has an ability value $v_i$, the tacit value between two students is $f...",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n, k_1, k_2 \\in \\mathbb{Z} $ with $ 1 \\leq n \\leq 10^6 $, $ 0 \\leq k_1, k_2 \\leq 2^{64} - 1 $.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of distinct positive integers ...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments