CF1634E.Fair Share

提高+/省选-

通过率:0%

时间限制:1.50s

内存限制:256MB

AC君温馨提醒

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

题目描述

Even a cat has things it can do that AI cannot.

— Fei-Fei Li

You are given mm arrays of positive integers. Each array is of even length.

You need to split all these integers into two equal multisets LL and RR, that is, each element of each array should go into one of two multisets (but not both). Additionally, for each of the mm arrays, exactly half of its elements should go into LL, and the rest should go into RR.

Give an example of such a division or determine that no such division exists.

即使是猫,也有 AI 无法做到的事情。

——李飞飞

给你 mm 个正整数数组,每个数组的长度均为偶数。

你需要将所有这些整数划分为两个大小相等的多重集 LL 和 RR,即每个数组中的每个元素都必须被分配到 LL 或 RR 中(但不能同时属于两者)。此外,对于这 mm 个数组中的每一个,其恰好一半的元素需进入 LL,其余一半则进入 RR。

请给出这样一种划分方案的例子,或判定这样的划分不存在。

输入格式

The first line contains an integer mm (1≤m≤1051 \le m \le 10 ^ 5) — the number of arrays.

The next 2⋅m2 \cdot m lines contain descriptions of the arrays.

For each array, the first line contains an even integer nn (2≤n≤2⋅1052 \le n \le 2 \cdot 10 ^ 5) — the length of the array. The second line consists of nn space-separated integers a1,a2,…,ana_1, a_2, \dots, a_n (1≤ai≤1091 \le a_i \le 10 ^ 9) — array elements.

It is guaranteed that the sum of nn over all arrays does not exceed 2⋅1052 \cdot 10^5.

第一行包含一个整数 mm(1≤m≤1051 \le m \le 10 ^ 5)—— 数组的个数。

接下来的 2⋅m2 \cdot m 行包含各数组的描述。

对于每个数组,第一行包含一个偶数 nn(2≤n≤2⋅1052 \le n \le 2 \cdot 10 ^ 5)—— 数组的长度;第二行包含 nn 个以空格分隔的整数 a1,a2,…,ana_1, a_2, \dots, a_n(1≤ai≤1091 \le a_i \le 10 ^ 9)—— 数组元素。

保证所有数组的 nn 值之和不超过 2⋅1052 \cdot 10^5。

输出格式

If the answer exists, print "YES", and then print mm lines.

On each line, for each element, print the letter "L" or "R" (capitalized, without spaces), depending on which multiset the element should go into.

If there is no answer, print "NO" on the only line.

如果答案存在,输出“YES”,然后输出 mm 行。
每行中,对每个元素,根据该元素应放入哪个多重集,输出大写字母 “L” 或 “R”(不带空格)。
如果不存在答案,则仅在单独一行中输出 “NO”。

输入输出样例

  • 输入#1

    3
    2
    1 2
    4
    1 2 3 3
    6
    1 1 2 2 3 3

    输出#1

    YES
    RL
    LRLR
    RLLRRL

说明/提示

In the first array, we add the first element to RR and the second to LL. Now L=2L = {2}, and R=1R = {1}.

In the second array, we add the first and third elements to LL and the rest to RR. Now L=1,2,3L = {1, 2, 3} and R=1,2,3R = {1, 2, 3}.

In the third array, we add elements 2, 3, and 6 to LL, and others — to RR. As a result, L=R=1,1,2,2,3,3L = R = {1, 1, 2, 2, 3, 3}.

在第一个数组中,我们将第一个元素加入 RR,第二个元素加入 LL。此时 L={2}L = \{2\},R={1}R = \{1\}。

在第二个数组中,我们将第一和第三个元素加入 LL,其余元素加入 RR。此时 L={1,2,3}L = \{1, 2, 3\},R={1,2,3}R = \{1, 2, 3\}。

在第三个数组中,我们将第 2、3、6 个元素加入 LL,其余元素加入 RR。最终得到 L=R={1,1,2,2,3,3}L = R = \{1, 1, 2, 2, 3, 3\}。

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

首页