309164: CF1634E. Fair Share

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Fair Share

题意翻译

给定 $m$ 个数组,第 $i$ 个数组包含 $n_i$ 个整数 $a_{i,1},a_{i,2},\dots,a_{i,n_i}$,保证 $2\mid n_i$。另外还有两个初始为空的可重集 $L,R$,你需要对于 $i=1,2,\dots,m$ 依次执行如下操作: - 将第 $i$ 个数组中的所有数当中选出 $\frac{n_i}{2}$ 个数放入 $L$ 中,另一半则放入 $R$ 中。 你需要保证在每一个数组内的所有数都放入两个可重集之后,都有 $L=R$ 成立。请给出一种放置 $m$ 个数组中的数的方案,或者判断不存在这样一种方案。 数据范围: - $1\leqslant m_i\leqslant 10^5$。 - $2\leqslant n_i,\sum n_i\leqslant 2\times 10^5$。 - $1\leqslant a_i\leqslant 10^9$。 Translated by Eason_AC 2022.2.9

题目描述

Even a cat has things it can do that AI cannot. — Fei-Fei Li You are given $ m $ arrays of positive integers. Each array is of even length. You need to split all these integers into two equal multisets $ L $ and $ R $ , that is, each element of each array should go into one of two multisets (but not both). Additionally, for each of the $ m $ arrays, exactly half of its elements should go into $ L $ , and the rest should go into $ R $ . Give an example of such a division or determine that no such division exists.

输入输出格式

输入格式


The first line contains an integer $ m $ ( $ 1 \le m \le 10 ^ 5 $ ) — the number of arrays. The next $ 2 \cdot m $ lines contain descriptions of the arrays. For each array, the first line contains an even integer $ n $ ( $ 2 \le n \le 2 \cdot 10 ^ 5 $ ) — the length of the array. The second line consists of $ n $ space-separated integers $ a_1, a_2, \dots, a_n $ ( $ 1 \le a_i \le 10 ^ 9 $ ) — array elements. It is guaranteed that the sum of $ n $ over all arrays does not exceed $ 2 \cdot 10^5 $ .

输出格式


If the answer exists, print "YES", and then print $ m $ 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.

输入输出样例

输入样例 #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 $ R $ and the second to $ L $ . Now $ L = \{2\} $ , and $ R = \{1\} $ . In the second array, we add the first and third elements to $ L $ and the rest to $ R $ . Now $ L = \{1, 2, 3\} $ and $ R = \{1, 2, 3\} $ . In the third array, we add elements 2, 3, and 6 to $ L $ , and others — to $ R $ . As a result, $ L = R = \{1, 1, 2, 2, 3, 3\} $ .

Input

题意翻译

给定 $m$ 个数组,第 $i$ 个数组包含 $n_i$ 个整数 $a_{i,1},a_{i,2},\dots,a_{i,n_i}$,保证 $2\mid n_i$。另外还有两个初始为空的可重集 $L,R$,你需要对于 $i=1,2,\dots,m$ 依次执行如下操作: - 将第 $i$ 个数组中的所有数当中选出 $\frac{n_i}{2}$ 个数放入 $L$ 中,另一半则放入 $R$ 中。 你需要保证在每一个数组内的所有数都放入两个可重集之后,都有 $L=R$ 成立。请给出一种放置 $m$ 个数组中的数的方案,或者判断不存在这样一种方案。 数据范围: - $1\leqslant m_i\leqslant 10^5$。 - $2\leqslant n_i,\sum n_i\leqslant 2\times 10^5$。 - $1\leqslant a_i\leqslant 10^9$。 Translated by Eason_AC 2022.2.9

加入题单

上一题 下一题 算法标签: