A. The Artful Expedient

Codeforces
IDCF869A
Time1000ms
Memory256MB
Difficulty
brute forceimplementation
English · Original
Chinese · Translation
Formal · Original
_Rock... Paper!_ After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows. A positive integer _n_ is decided first. Both Koyomi and Karen independently choose _n_ distinct positive integers, denoted by _x_1, _x_2, ..., _x__n_ and _y_1, _y_2, ..., _y__n_ respectively. They reveal their sequences, and repeat until **all of 2_n_ integers become distinct**, which is the only final state to be kept and considered. Then they count the number of ordered pairs (_i_, _j_) (1 ≤ _i_, _j_ ≤ _n_) such that the value _x__i_ _xor_ _y__j_ equals to one of the 2_n_ integers. Here _xor_ means the [bitwise exclusive or](https://en.wikipedia.org/wiki/Bitwise_operation#XOR) operation on two integers, and is denoted by operators _^_ and/or _xor_ in most programming languages. Karen claims a win if the number of such pairs is even, and Koyomi does otherwise. And you're here to help determine the winner of their latest game. ## Input The first line of input contains a positive integer _n_ (1 ≤ _n_ ≤ 2 000) — the length of both sequences. The second line contains _n_ space-separated integers _x_1, _x_2, ..., _x__n_ (1 ≤ _x__i_ ≤ 2·106) — the integers finally chosen by Koyomi. The third line contains _n_ space-separated integers _y_1, _y_2, ..., _y__n_ (1 ≤ _y__i_ ≤ 2·106) — the integers finally chosen by Karen. Input guarantees that **the given 2_n_ integers are pairwise distinct**, that is, no pair (_i_, _j_) (1 ≤ _i_, _j_ ≤ _n_) exists such that one of the following holds: _x__i_ = _y__j_; _i_ ≠ _j_ and _x__i_ = _x__j_; _i_ ≠ _j_ and _y__i_ = _y__j_. ## Output Output one line — the name of the winner, that is, "_Koyomi_" or "_Karen_" (without quotes). Please be aware of the capitalization. [samples] ## Note In the first example, there are 6 pairs satisfying the constraint: (1, 1), (1, 2), (2, 1), (2, 3), (3, 2) and (3, 3). Thus, Karen wins since 6 is an even number. In the second example, there are 16 such pairs, and Karen wins again.
_Rock... Paper!_ 在Karen找到了石头剪刀布的确定性胜负策略后,她的弟弟Koyomi提出了一种新的替代游戏。游戏规则如下: 首先确定一个正整数 $n$。Koyomi和Karen各自独立地选择 $n$ 个互不相同的正整数,分别记为 $x_1, x_2, ..., x_n$ 和 $y_1, y_2, ..., y_n$。他们展示各自的序列,并重复此过程,直到 *所有 $2n$ 个整数互不相同*,此时为唯一保留并考虑的最终状态。 然后,他们统计满足条件的有序对 $(i, j)$($1 ≤ i, j ≤ n$)的数量,使得值 $x_i$ _xor_ $y_j$ 等于这 $2n$ 个整数中的某一个。这里 _xor_ 表示两个整数的按位异或运算,在大多数编程语言中用操作符 _^_ 和/或 _xor_ 表示。 如果这样的对的数量为偶数,Karen获胜;否则Koyomi获胜。你的任务是帮助确定他们最新一局游戏的胜者。 输入的第一行包含一个正整数 $n$($1 ≤ n ≤ 2 000$)——两个序列的长度。 第二行包含 $n$ 个用空格分隔的整数 $x_1, x_2, ..., x_n$($1 ≤ x_i ≤ 2·10^6$)——Koyomi最终选择的整数。 第三行包含 $n$ 个用空格分隔的整数 $y_1, y_2, ..., y_n$($1 ≤ y_i ≤ 2·10^6$)——Karen最终选择的整数。 输入保证给定的 $2n$ 个整数两两互不相同,即不存在任何一对 $(i, j)$($1 ≤ i, j ≤ n$)满足以下任一条件:$x_i = y_j$;$i ≠ j$ 且 $x_i = x_j$;$i ≠ j$ 且 $y_i = y_j$。 请输出一行——胜者的姓名,即 "_Koyomi_" 或 "_Karen_"(不含引号)。请注意大小写。 在第一个例子中,有 $6$ 个满足条件的对:$(1, 1)$、$(1, 2)$、$(2, 1)$、$(2, 3)$、$(3, 2)$ 和 $(3, 3)$。因此,由于 $6$ 是偶数,Karen获胜。 在第二个例子中,有 $16$ 个这样的对,Karen再次获胜。 ## Input 输入的第一行包含一个正整数 $n$($1 ≤ n ≤ 2 000$)——两个序列的长度。第二行包含 $n$ 个用空格分隔的整数 $x_1, x_2, ..., x_n$($1 ≤ x_i ≤ 2·10^6$)——Koyomi最终选择的整数。第三行包含 $n$ 个用空格分隔的整数 $y_1, y_2, ..., y_n$($1 ≤ y_i ≤ 2·10^6$)——Karen最终选择的整数。输入保证给定的 $2n$ 个整数两两互不相同,即不存在任何一对 $(i, j)$($1 ≤ i, j ≤ n$)满足以下任一条件:$x_i = y_j$;$i ≠ j$ 且 $x_i = x_j$;$i ≠ j$ 且 $y_i = y_j$。 ## Output 请输出一行——胜者的姓名,即 "_Koyomi_" 或 "_Karen_"(不含引号)。请注意大小写。 [samples] ## Note 在第一个例子中,有 $6$ 个满足条件的对:$(1, 1)$、$(1, 2)$、$(2, 1)$、$(2, 3)$、$(3, 2)$ 和 $(3, 3)$。因此,由于 $6$ 是偶数,Karen获胜。在第二个例子中,有 $16$ 个这样的对,Karen再次获胜。
**Definitions** Let $ n \in \mathbb{Z}^+ $ with $ 1 \leq n \leq 2000 $. Let $ X = \{x_1, x_2, \dots, x_n\} \subset \mathbb{Z}^+ $ and $ Y = \{y_1, y_2, \dots, y_n\} \subset \mathbb{Z}^+ $ be two sets of distinct positive integers such that $ X \cap Y = \emptyset $ and all $ 2n $ elements in $ X \cup Y $ are pairwise distinct. Let $ S = X \cup Y $. **Constraints** 1. $ 1 \leq x_i \leq 2 \cdot 10^6 $ for all $ i \in \{1, \dots, n\} $ 2. $ 1 \leq y_j \leq 2 \cdot 10^6 $ for all $ j \in \{1, \dots, n\} $ 3. $ |S| = 2n $ and all elements in $ S $ are distinct. **Objective** Compute the number of ordered pairs $ (i, j) \in \{1, \dots, n\}^2 $ such that: $$ x_i \oplus y_j \in S $$ where $ \oplus $ denotes bitwise XOR. Let $ C = \left| \left\{ (i,j) \mid x_i \oplus y_j \in S \right\} \right| $. Output "Koyomi" if $ C $ is odd, "Karen" if $ C $ is even.
Samples
Input #1
3
1 2 3
4 5 6
Output #1
Karen
Input #2
5
2 4 6 8 10
9 7 5 3 1
Output #2
Karen
API Response (JSON)
{
  "problem": {
    "name": "A. The Artful Expedient",
    "description": {
      "content": "_Rock... Paper!_ After Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows.",
      "description_type": "Markdown"
    },
    "platform": "Codeforces",
    "limit": {
      "time_limit": 1000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "CF869A"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "_Rock... Paper!_\n\nAfter Karen have found the deterministic winning (losing?) strategy for rock-paper-scissors, her brother, Koyomi, comes up with a new game as a substitute. The game works as follows....",
      "is_translate": false,
      "language": "English"
    },
    {
      "statement_type": "Markdown",
      "content": "_Rock... Paper!_\n\n在Karen找到了石头剪刀布的确定性胜负策略后,她的弟弟Koyomi提出了一种新的替代游戏。游戏规则如下:\n\n首先确定一个正整数 $n$。Koyomi和Karen各自独立地选择 $n$ 个互不相同的正整数,分别记为 $x_1, x_2, ..., x_n$ 和 $y_1, y_2, ..., y_n$。他们展示各自的序列,并重复此过程,直到 *所有 $2n$ 个...",
      "is_translate": true,
      "language": "Chinese"
    },
    {
      "statement_type": "Markdown",
      "content": "**Definitions**  \nLet $ n \\in \\mathbb{Z}^+ $ with $ 1 \\leq n \\leq 2000 $.  \nLet $ X = \\{x_1, x_2, \\dots, x_n\\} \\subset \\mathbb{Z}^+ $ and $ Y = \\{y_1, y_2, \\dots, y_n\\} \\subset \\mathbb{Z}^+ $ be two s...",
      "is_translate": false,
      "language": "Formal"
    }
  ]
}
Full JSON Raw Segments