exec_outcome
stringclasses 1
value | code_uid
stringlengths 32
32
| file_name
stringclasses 111
values | prob_desc_created_at
stringlengths 10
10
| prob_desc_description
stringlengths 63
3.8k
| prob_desc_memory_limit
stringclasses 18
values | source_code
stringlengths 117
65.5k
| lang_cluster
stringclasses 1
value | prob_desc_sample_inputs
stringlengths 2
802
| prob_desc_time_limit
stringclasses 27
values | prob_desc_sample_outputs
stringlengths 2
796
| prob_desc_notes
stringlengths 4
3k
⌀ | lang
stringclasses 5
values | prob_desc_input_from
stringclasses 3
values | tags
sequencelengths 0
11
| src_uid
stringlengths 32
32
| prob_desc_input_spec
stringlengths 28
2.37k
⌀ | difficulty
int64 -1
3.5k
⌀ | prob_desc_output_spec
stringlengths 17
1.47k
⌀ | prob_desc_output_to
stringclasses 3
values | hidden_unit_tests
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PASSED | 7a2540e9a3cbe4e959c6ddf84c048db7 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class Practice {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw = new PrintWriter(new BufferedWriter(new PrintWriter(System.out)));
StringBuilder sb = new StringBuilder();
StringTokenizer st = new StringTokenizer(br.readLine());
int t = Integer.parseInt(st.nextToken());
while (t --> 0) {
st = new StringTokenizer(br.readLine());
int n = Integer.parseInt(st.nextToken());
int r = Integer.parseInt(st.nextToken());
int b = Integer.parseInt(st.nextToken());
int red = r / (b + 1);
int set = red + 1;
int tot = set * b;
n -= (tot + red);
String add = "";
for (int i = 0; i < red; i++) add += "R";
add += "B";
String test = "";
for (int i = 0; i < b; i++) {
if (n-- > 0) test += "R";
test += add;
}
for (int i = 0; i < red; i++) test += "R";
sb.append(test);
sb.append("\n");
}
pw.println(sb.toString().trim());
pw.close();
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | a90d5f778154869f8ecf08bb727bef7d | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | /**
*
* @author wilso
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class codeforces {
static final long MOD = 1_000_000_007;
static final long X = 10000000000L;
static final int[][] dirs = new int[][] {{1, 0}, {-1, 0}, {0, 1}, {0, -1}};
static Set<Long> facts;
public static void main(String[] args) {
FastScanner sc = new FastScanner();
PrintWriter pw = new PrintWriter(System.out);
// Scanner sc = new Scanner(System.in);
// int tc = 1;
int tc = sc.ni();
for (int tt = 0; tt < tc; tt++) {
int N = sc.ni();
int r = sc.ni();
int b = sc.ni();
pw.println(solve(N,r,b));
}
pw.close();
}
static String solve(int N, int r, int b) {
int save = r ;
int div = b + 1;
int ans = save/div;
if (save %div != 0) ans++;
StringBuilder sb = new StringBuilder();
for (int rep = 0; rep < N; rep++) {
if (ans == 1) {
if (rep % 2 == 0) {
sb.append("R");
r--;
}
else {
sb.append("B");
b--;
}
}
else {
if (rep % (ans+1) == ans) {
sb.append("B");
b--;
}
else {
sb.append("R");
r--;
}
}
if (b - r <= 1 && b-r >= 0) {
int alter = 0;
for (int i = rep+1; i < N; i++) {
if (alter == 0) {
sb.append("B");
}
else {
sb.append("R");
}
alter = 1-alter;
}
break;
}
}
return sb.toString();
}
//method extracted from uwi
public static int[] sieveEratosthenes(int n) {
if (n <= 32) {
int[] primes = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
for (int i = 0; i < primes.length; i++) {
if (n < primes[i]) {
return Arrays.copyOf(primes, i);
}
}
return primes;
}
int u = n + 32;
double lu = Math.log(u);
int[] ret = new int[(int) (u / lu + u / lu / lu * 1.5)];
ret[0] = 2;
int pos = 1;
int[] isnp = new int[(n + 1) / 32 / 2 + 1];
int sup = (n + 1) / 32 / 2 + 1;
int[] tprimes = { 3, 5, 7, 11, 13, 17, 19, 23, 29, 31 };
for (int tp : tprimes) {
ret[pos++] = tp;
int[] ptn = new int[tp];
for (int i = (tp - 3) / 2; i < tp << 5; i += tp)
ptn[i >> 5] |= 1 << (i & 31);
for (int j = 0; j < sup; j += tp) {
for (int i = 0; i < tp && i + j < sup; i++) {
isnp[j + i] |= ptn[i];
}
}
}
// 3,5,7
// 2x+3=n
int[] magic = { 0, 1, 23, 2, 29, 24, 19, 3, 30, 27, 25, 11, 20, 8, 4,
13, 31, 22, 28, 18, 26, 10, 7, 12, 21, 17, 9, 6, 16, 5, 15, 14 };
int h = n / 2;
for (int i = 0; i < sup; i++) {
for (int j = ~isnp[i]; j != 0; j &= j - 1) {
int pp = i << 5 | magic[(j & -j) * 0x076be629 >>> 27];
int p = 2 * pp + 3;
if (p > n)
break;
ret[pos++] = p;
if ((long) p * p > n)
continue;
for (int q = (p * p - 3) / 2; q <= h; q += p)
isnp[q >> 5] |= 1 << q;
}
}
return Arrays.copyOf(ret, pos);
}
static long factorial(long x) {
if (x <= 1) return 1;
return (x * (factorial(x-1) % MOD) % MOD);
}
static int greaterThan(long[] arr, long target) {
int lo = 0, hi = arr.length- 1;
while(lo < hi) { // observe this time it is "<" operator, not "<="
int mid = lo + (hi-lo)/2;
if(arr[mid] <= target) lo = mid+1;
else hi = mid;
}
return arr[lo] > target ? lo : -1;
}
static int smallerThan(long[] arr, long target) {
int lo = 0, hi = arr.length- 1;
while(lo < hi) {
int mid = lo + (hi-lo+1)/2; // Note that I used ceil here otherwise it could go in infinite loop
if(arr[mid] < target) lo = mid;
else hi = mid-1;
}
return arr[lo] < target ? lo : -1;
}
static int[] reduce(int[] temp) {
int[] frac = new int[] {temp[0], temp[1]};
int curr = gcd(frac[0], frac[1]);
while (curr != 1) {
frac[0] /= curr;
frac[1] /= curr;
curr = gcd(frac[0], frac[1]);
}
return frac;
}
static int summation(int x) {
return x * (x+1) / 2;
}
static long summation(long x) {
return x*(x+1) / 2;
}
static long pow(long num, long exp, long mod){
long ans=1;
for(int i=1;i<=exp;i++){
ans=(ans*num)%mod;
}
return ans;
}
static boolean isPrime(int n)
{
if (n <= 1)
return false;
else if (n == 2)
return true;
else if (n % 2 == 0)
return false;
for (int i = 3; i <= Math.sqrt(n); i += 2) {
if (n % i == 0)
return false;
}
return true;
}
static int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
static long gcd(long a, long b) {
if (a == 0) return b;
return gcd(b % a, a);
}
static int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
public static void sort(int[] arr) {
Random rgen = new Random();
for (int i = 0; i < arr.length; i++) {
int r = rgen.nextInt(arr.length);
int temp = arr[i];
arr[i] = arr[r];
arr[r] = temp;
}
Arrays.sort(arr);
}
public static void sort(long[] arr) {
Random rgen = new Random();
for (int i = 0; i < arr.length; i++) {
int r = rgen.nextInt(arr.length);
long temp = arr[i];
arr[i] = arr[r];
arr[r] = temp;
}
Arrays.sort(arr);
}
static int charint(char c) {
return Integer.parseInt(String.valueOf(c));
}
/* */
//printing methods
/* */
//WOW!
/* */
public static void printArr(PrintWriter pw, int[] arr) {
StringBuilder sb = new StringBuilder();
for (int x : arr) {
sb.append(x + "");
}
sb.setLength(sb.length() - 1);
pw.println(sb.toString());
}
public static void printArr2d(PrintWriter pw, int[][] arr) {
StringBuilder sb = new StringBuilder();
for (int[] row : arr) {
for (int x : row) {
sb.append(x + " ");
}
sb.setLength(sb.length() - 1);
sb.append("\n");
}
pw.println(sb.toString());
}
}
class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in), 32768);
st = null;
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int ni() {
return Integer.parseInt(next());
}
int[] intArray(int N) {
int[] ret = new int[N];
for (int i = 0; i < N; i++)
ret[i] = ni();
return ret;
}
long nl() {
return Long.parseLong(next());
}
long[] longArray(int N) {
long[] ret = new long[N];
for (int i = 0; i < N; i++)
ret[i] = nl();
return ret;
}
double nd() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
class MultiSet {
TreeMap<Long, Integer> map = new TreeMap<>();
private int size = 0;
public MultiSet() {
}
public void add(Long val) {
map.put(val, map.getOrDefault(val, 0) + 1);
size++;
}
public void remove(Long val) {
map.put(val, map.get(val) - 1);
if (map.get(val) == 0) {
map.remove(val);
}
size--;
}
public int size() {
return size;
}
public Long higher(Long val) {
return map.higherKey(val);
}
public Long lower(Long val) {
return map.lowerKey(val);
}
public Long ceiling(Long val) {
return map.ceilingKey(val);
}
public Long floor(Long val) {
return map.floorKey(val);
}
public Long first() {
return map.firstKey();
}
public Long last() {
return map.lastKey();
}
public boolean isEmpty() {
return map.isEmpty();
}
}
class State {
public int weight;
public int node;
public State(int node, int weight) {
this.node = node;
this.weight = weight;
}
}
class UnionFind {
int[] id;
public UnionFind(int size) {
id = new int[size];
for (int i = 0; i < id.length; i++) {
id[i] = i;
}
}
public int find(int a) {
if (id[a] != a) {
id[a] = find(id[a]);
}
return id[a];
}
public void union(int a, int b) {
int r1 = find(a);
int r2 = find(b);
if (r1 == r2)
return;
id[r1] = r2;
}
}
class Solution {
public long findMaximumXOR(long[] nums) {
Trie root = new Trie();
long ans = 0, max = 0;
int depth = 0; //depth of trie
for (long n : nums) max = Math.max(n, max);
for (;max > 0; max >>= 1) depth++; //depth = max num binary string length
for (long n : nums){
long sum = 0;
Trie cur = root, tmp = cur; //cur for adding n into Trie, tmp for finding the max path
for (int i = depth - 1; i >= 0; i--){
sum <<= 1;
long d = (n & (1 << i)) > 0? 1 : 0; //start checking from left end. 1 if positive, 0 if 0.
if (cur.nodes[(int)d] == null) cur.nodes[(int)d] = new Trie();
if (tmp.nodes[(int)(1 - d)] != null) sum++; //always choose the opposite path if they exist
cur = cur.nodes[(int)d];
tmp = sum % 2 == 0? tmp.nodes[(int)d] : tmp.nodes[(int)(1 - d)];
}
ans = Math.max(sum, ans);
}
return ans;
}
private class Trie{
Trie[] nodes;
Trie(){
nodes = new Trie[2];
}
}
}
class SegTreeRMQ {
int leftMost, rightMost;
long miny;
SegTreeRMQ left, right;
long[] a;
public SegTreeRMQ(long[] a, int leftMost, int rightMost) {
this.a = a;
this.leftMost = leftMost;
this.rightMost = rightMost;
int mid = (rightMost + leftMost) / 2;
if (leftMost == rightMost) {
miny = a[leftMost];
} else {
left = new SegTreeRMQ(a, leftMost, mid);
right = new SegTreeRMQ(a, mid + 1, rightMost);
recalc();
}
}
private void recalc() {
if (leftMost == rightMost)
return;
miny = Math.min(right.miny, left.miny);
}
void pointUpdate(int index, int newVal) {
if (leftMost == rightMost) {
miny = newVal;
return;
}
if (index <= left.rightMost)
left.pointUpdate(index, newVal);
else
right.pointUpdate(index, newVal);
recalc();
}
long rangeMin(int l, int r) {
// three cases:
// 1. not intersected
if (r < leftMost || rightMost < l)
return Long.MAX_VALUE;
// 2. partially contained
if (l <= leftMost && r >= rightMost)
return miny;
// 3. don't know
return Math.min(left.rangeMin(l, r), right.rangeMin(l, r));
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 44ae94d74a0c04d4a247cf9cf497f289 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
public class Red_Versus_Blue {
public static void main(String[] args) {
Scanner sc= new Scanner(System.in);
int t = sc.nextInt();
while(t>0){
int n= sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
int min = r/(b+1);
int rest = r%(b+1);
StringBuilder str = new StringBuilder();
StringBuilder ans = new StringBuilder();
for(int i=0;i<min;i++){
str.append("R");
}
for(int i=0;i<b+1;i++){
ans.append(str.toString());
if(rest!=0){
ans.append("R");
rest--;
}
if(i!=b){
ans.append("B");
}
}
System.out.println(ans.toString());
t--;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | f26d7af08b4b5273062d093f23c44f8a | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0){
t--;
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
String s="";
while(b>0){
int divide=r/(b+1);
if(divide*(b+1)!=r){
divide=divide+1;
}
while(divide>0){
s+="R";
divide--;
r--;
}
s+='B';
b--;
}
while(r>0){
s+='R';
r--;
}
System.out.println(s);
}
}
public static int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 317540afea11cf5d3dd8e589d3b5d674 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static final PrintWriter out =new PrintWriter(System.out);
static final FastReader sc = new FastReader();
//I invented a new word!Plagiarism!
//Did you hear about the mathematician who’s afraid of negative numbers?He’ll stop at nothing to avoid them
//What do Alexander the Great and Winnie the Pooh have in common? Same middle name.
//I finally decided to sell my vacuum cleaner. All it was doing was gathering dust!
//ArrayList<Integer> a=new ArrayList <Integer>();
//PriorityQueue<Integer> pq=new PriorityQueue<>();
//char[] a = s.toCharArray();
// char s[]=sc.next().toCharArray();
public static boolean sorted(int a[])
{
int n=a.length,i;
int b[]=new int[n];
for(i=0;i<n;i++)
b[i]=a[i];
Arrays.sort(b);
for(i=0;i<n;i++)
{
if(a[i]!=b[i])
return false;
}
return true;
}
public static void main (String[] args) throws java.lang.Exception
{
int tes=sc.nextInt();
while(tes-->0)
{
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
String s="";
String S="";
String ns="";
int p=r/(b+1);
int q=r%(b+1),i;
for(i=1;i<=p+1;i++)
s+='R';
s+='B';
for(i=1;i<=p;i++)
S+='R';
S+='B';
for(i=1;i<=q;i++)
ns+=s;
for(i=1;i<=b-q+1;i++)
ns+=S;
System.out.println(ns.substring(0,n));
}
}
public static int first(ArrayList<Integer> arr, int low, int high, int x, int n)
{
if (high >= low) {
int mid = low + (high - low) / 2;
if ((mid == 0 || x > arr.get(mid-1)) && arr.get(mid) == x)
return mid;
else if (x > arr.get(mid))
return first(arr, (mid + 1), high, x, n);
else
return first(arr, low, (mid - 1), x, n);
}
return -1;
}
public static int last(ArrayList<Integer> arr, int low, int high, int x, int n)
{
if (high >= low) {
int mid = low + (high - low) / 2;
if ((mid == n - 1 || x < arr.get(mid+1)) && arr.get(mid) == x)
return mid;
else if (x < arr.get(mid))
return last(arr, low, (mid - 1), x, n);
else
return last(arr, (mid + 1), high, x, n);
}
return -1;
}
public static int lis(int[] arr) {
int n = arr.length;
ArrayList<Integer> al = new ArrayList<Integer>();
al.add(arr[0]);
for(int i = 1 ; i<n;i++) {
int x = al.get(al.size()-1);
if(arr[i]>=x) {
al.add(arr[i]);
}else {
int v = upper_bound(al, 0, al.size(), arr[i]);
al.set(v, arr[i]);
}
}
return al.size();
}
public static int lower_bound(ArrayList<Long> ar,int lo , int hi , long k)
{
Collections.sort(ar);
int s=lo;
int e=hi;
while (s !=e)
{
int mid = s+e>>1;
if (ar.get((int)mid) <k)
{
s=mid+1;
}
else
{
e=mid;
}
}
if(s==ar.size())
{
return -1;
}
return s;
}
public static int upper_bound(ArrayList<Integer> ar,int lo , int hi, int k)
{
Collections.sort(ar);
int s=lo;
int e=hi;
while (s !=e)
{
int mid = s+e>>1;
if (ar.get(mid) <=k)
{
s=mid+1;
}
else
{
e=mid;
}
}
if(s==ar.size())
{
return -1;
}
return s;
}
static boolean isPrime(long N)
{
if (N<=1) return false;
if (N<=3) return true;
if (N%2 == 0 || N%3 == 0) return false;
for (int i=5; i*i<=N; i=i+6)
if (N%i == 0 || N%(i+2) == 0)
return false;
return true;
}
static int countBits(long a)
{
return (int)(Math.log(a)/Math.log(2)+1);
}
static long fact(long N)
{
long mod=1000000007;
long n=2;
if(N<=1)return 1;
else
{
for(int i=3; i<=N; i++)n=(n*i)%mod;
}
return n;
}
private static boolean isInteger(String s) {
try {
Integer.parseInt(s);
} catch (NumberFormatException e) {
return false;
} catch (NullPointerException e) {
return false;
}
return true;
}
private static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
private static long lcm(long a, long b) {
return (a / gcd(a, b)) * b;
}
private static boolean isPalindrome(String str) {
int i = 0, j = str.length() - 1;
while (i < j)
if (str.charAt(i++) != str.charAt(j--))
return false;
return true;
}
private static String reverseString(String str) {
StringBuilder sb = new StringBuilder(str);
return sb.reverse().toString();
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | e87079d5bd08d3c2e994b2daea1f3e77 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static final PrintWriter out =new PrintWriter(System.out);
static final FastReader sc = new FastReader();
//I invented a new word!Plagiarism!
//Did you hear about the mathematician who’s afraid of negative numbers?He’ll stop at nothing to avoid them
//What do Alexander the Great and Winnie the Pooh have in common? Same middle name.
//I finally decided to sell my vacuum cleaner. All it was doing was gathering dust!
//ArrayList<Integer> a=new ArrayList <Integer>();
//PriorityQueue<Integer> pq=new PriorityQueue<>();
//char[] a = s.toCharArray();
// char s[]=sc.next().toCharArray();
public static boolean sorted(int a[])
{
int n=a.length,i;
int b[]=new int[n];
for(i=0;i<n;i++)
b[i]=a[i];
Arrays.sort(b);
for(i=0;i<n;i++)
{
if(a[i]!=b[i])
return false;
}
return true;
}
public static void main (String[] args) throws java.lang.Exception
{
int tes=sc.nextInt();
while(tes-->0)
{
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
String s="";
String S="";
String ns="";
int p=r/(b+1);
int q=r%(b+1),i;
for(i=1;i<=p+1;i++)
s+='R';
s+='B';
for(i=1;i<=p;i++)
S+='R';
S+='B';
for(i=1;i<=q;i++)
ns+=s;
for(i=1;i<=b-q+1;i++)
ns+=S;
System.out.println(ns.substring(0,n));
}
}
public static int first(ArrayList<Integer> arr, int low, int high, int x, int n)
{
if (high >= low) {
int mid = low + (high - low) / 2;
if ((mid == 0 || x > arr.get(mid-1)) && arr.get(mid) == x)
return mid;
else if (x > arr.get(mid))
return first(arr, (mid + 1), high, x, n);
else
return first(arr, low, (mid - 1), x, n);
}
return -1;
}
public static int last(ArrayList<Integer> arr, int low, int high, int x, int n)
{
if (high >= low) {
int mid = low + (high - low) / 2;
if ((mid == n - 1 || x < arr.get(mid+1)) && arr.get(mid) == x)
return mid;
else if (x < arr.get(mid))
return last(arr, low, (mid - 1), x, n);
else
return last(arr, (mid + 1), high, x, n);
}
return -1;
}
public static int lis(int[] arr) {
int n = arr.length;
ArrayList<Integer> al = new ArrayList<Integer>();
al.add(arr[0]);
for(int i = 1 ; i<n;i++) {
int x = al.get(al.size()-1);
if(arr[i]>=x) {
al.add(arr[i]);
}else {
int v = upper_bound(al, 0, al.size(), arr[i]);
al.set(v, arr[i]);
}
}
return al.size();
}
public static int lower_bound(ArrayList<Long> ar,int lo , int hi , long k)
{
Collections.sort(ar);
int s=lo;
int e=hi;
while (s !=e)
{
int mid = s+e>>1;
if (ar.get((int)mid) <k)
{
s=mid+1;
}
else
{
e=mid;
}
}
if(s==ar.size())
{
return -1;
}
return s;
}
public static int upper_bound(ArrayList<Integer> ar,int lo , int hi, int k)
{
Collections.sort(ar);
int s=lo;
int e=hi;
while (s !=e)
{
int mid = s+e>>1;
if (ar.get(mid) <=k)
{
s=mid+1;
}
else
{
e=mid;
}
}
if(s==ar.size())
{
return -1;
}
return s;
}
static boolean isPrime(long N)
{
if (N<=1) return false;
if (N<=3) return true;
if (N%2 == 0 || N%3 == 0) return false;
for (int i=5; i*i<=N; i=i+6)
if (N%i == 0 || N%(i+2) == 0)
return false;
return true;
}
static int countBits(long a)
{
return (int)(Math.log(a)/Math.log(2)+1);
}
static long fact(long N)
{
long mod=1000000007;
long n=2;
if(N<=1)return 1;
else
{
for(int i=3; i<=N; i++)n=(n*i)%mod;
}
return n;
}
private static boolean isInteger(String s) {
try {
Integer.parseInt(s);
} catch (NumberFormatException e) {
return false;
} catch (NullPointerException e) {
return false;
}
return true;
}
private static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
private static long lcm(long a, long b) {
return (a / gcd(a, b)) * b;
}
private static boolean isPalindrome(String str) {
int i = 0, j = str.length() - 1;
while (i < j)
if (str.charAt(i++) != str.charAt(j--))
return false;
return true;
}
private static String reverseString(String str) {
StringBuilder sb = new StringBuilder(str);
return sb.reverse().toString();
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 599197331ed543aac7b1b45c3cbf1e68 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.*;
import javax.print.attribute.HashAttributeSet;
import javax.print.attribute.SetOfIntegerSyntax;
public class codeforces{
//_______</>*SOLVE*</>_________//
static void solve(){
int n=input.nextInt();
int r=input.nextInt();
int b=input.nextInt();
int gapfill=r/(b+1);
if(gapfill*(b+1)!=r){
gapfill++;
}
//System.out.println(gapfill);
StringBuilder str=new StringBuilder("");
while(n>0){
for(int i=0;i<gapfill&&r>0;i++){
str.append("R");
r--;
}
if(b>0){
str.append("B");
b--;
}
gapfill=r/(b+1);
if(gapfill*(b+1)!=r){
gapfill++;
}
n--;
}
System.out.println(str);
}
//_______</>*MAIN*</>__________//
public static void main(String[] args) throws IOException {
int t=input.nextInt();
while(t-->0){
solve();
}
}
static FastReader input=new FastReader();
static PrintWriter out=new PrintWriter(System.out);
//_______</>INPUT READER FUNCTIONS</>__________//
static int[] input1dArray(int n){
int[] arr=new int[n];
for(int i=0;i<n;i++){
arr[i]=input.nextInt();
}
return arr;
}
static int[][] input2dArray(int n,int m){
int[][] arr=new int[n][m];
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
arr[i][j]=input.nextInt();
}
}
return arr;
}
static List<Integer> inputIntList(int n){
List<Integer> arr=new ArrayList<Integer>();
for(int i=0;i<n;i++){
arr.add(input.nextInt());
}
return arr;
}
static char[] inputCharArray(int n,String str){
char[] arr=new char[n];
for(int i=0;i<n;i++){
arr[i]=str.charAt(i);
}
return arr;
}
//_______</>OUTPUT</>__________//
static void print1darray(int arr[],int n){
for(int i=0;i<n;i++){
out.print(arr[i]+" ");
}out.println("");
}
//_______</>int array to set</>__________//
static Set<Integer> setFromIntArray(int[] arr,int n){
Set<Integer> set=new HashSet<>();
for(int i=0;i<n;i++){
set.add(arr[i]);
}
return set;
}
//_______</>map from int array</>__________//
static HashMap<Integer,Integer> MapFromIntArray(int n,int arr[]) throws IOException{
HashMap<Integer,Integer> map=new HashMap<>();
for(int i=0;i<n;i++){
int toadd=arr[i];
if(map.containsKey(toadd)){
map.put(toadd, map.get(toadd)+1);
}else{
map.put(toadd, 0);
}
}
return map;
}
static class FastReader {
BufferedReader br;
StringTokenizer st;public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
if(st.hasMoreTokens()){
str = st.nextToken("\n");
}
else{
str = br.readLine();
}
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 0fba564d40199d9b42810600e459f2a2 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class Solution{
public static void main(String[] args) {
TaskA solver = new TaskA();
int t = in.nextInt();
for (int i = 1; i <= t ; i++) {
solver.solve(i, in, out);
}
// solver.solve(1, in, out);
out.flush();
out.close();
}
static class TaskA {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n= in.nextInt();
char[]c=new char[n];
int r=in.nextInt();
int b= in.nextInt();
int diff=ceil(r,(b+1));
int i=0;int ct=0;
while(i<n) {
int j=i;
for(j=i;j<i+diff&&j<n;j++) {
c[j]='R';
}
i=j;
if(j<n) {
c[i]='B';i++;ct++;
}
}
ct=b-ct;int ind=0;
while(ct>0) {
if(c[ind]=='R'&&ind+1<n&&c[ind+1]=='B') {
c[ind]='B';ct--;
}
ind++;
}
println(String.valueOf(c));
}
}
static int ceil(int a,int b) {
int ans=a/b;if(a%b!=0) {
ans++;
}
return ans;
}
static int query(int l,int r) {
System.out.println("? "+l+" "+r);
System.out.print ("\n");
int x=in.nextInt();
return x;
}
static boolean check(Pair[]arr,int mid,int n) {
int c=0;
for(int i=0;i<n;i++) {
if(mid-1-arr[i].first<=c&&c<=arr[i].second) {
c++;
}
}
return c>=mid;
}
static long sum(int[]arr) {
long s=0;
for(int x:arr) {
s+=x;
}
return s;
}
static long sum(long[]arr) {
long s=0;
for(long x:arr) {
s+=x;
}
return s;
}
static int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
static void sort(int[] a) {
ArrayList<Integer> q = new ArrayList<>();
for (int i : a) q.add(i);
Collections.sort(q);
for (int i = 0; i < a.length; i++) a[i] = q.get(i);
}
static void sort(long[] a) {
ArrayList<Long> q = new ArrayList<>();
for (long i : a) q.add(i);
Collections.sort(q);
for (int i = 0; i < a.length; i++) a[i] = q.get(i);
}
static void println(int[][]arr) {
for(int i=0;i<arr.length;i++) {
for(int j=0;j<arr[0].length;j++) {
print(arr[i][j]+" ");
}
print("\n");
}
}
static void println(long[][]arr) {
for(int i=0;i<arr.length;i++) {
for(int j=0;j<arr[0].length;j++) {
print(arr[i][j]+" ");
}
print("\n");
}
}
static void println(int[]arr){
for(int i=0;i<arr.length;i++) {
print(arr[i]+" ");
}
print("\n");
}
static void println(long[]arr){
for(int i=0;i<arr.length;i++) {
print(arr[i]+" ");
}
print("\n");
}
static long[]input(int n){
long[]arr=new long[n];
for(int i=0;i<n;i++) {
arr[i]=in.nextInt();
}
return arr;
}
static long[]input(){
long n= in.nextInt();
long[]arr=new long[(int)n];
for(int i=0;i<n;i++) {
arr[i]=in.nextLong();
}
return arr;
}
////////////////////////////////////////////////////////
static class Pair {
long first;
long second;
Pair(long x, long y)
{
this.first = x;
this.second = y;
}
}
static void sortS(Pair arr[])
{
Arrays.sort(arr, new Comparator<Pair>() {
@Override public int compare(Pair p1, Pair p2)
{
return (int)(p1.second - p2.second);
}
});
}
static void sortF(Pair arr[])
{
Arrays.sort(arr, new Comparator<Pair>() {
@Override public int compare(Pair p1, Pair p2)
{
return (int)(p1.first - p2.first);
}
});
}
/////////////////////////////////////////////////////////////
static InputStream inputStream = System.in;
static OutputStream outputStream = System.out;
static InputReader in = new InputReader(inputStream);
static PrintWriter out = new PrintWriter(outputStream);
static void println(long c) {
out.println(c);
}
static void print(long c) {
out.print(c);
}
static void print(int c) {
out.print(c);
}
static void println(int x) {
out.println(x);
}
static void print(String s) {
out.print(s);
}
static void println(String s) {
out.println(s);
}
static void println(boolean b) {
out.println(b);
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | b384b286733d09121258c73ef76929b0 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class Solution{
public static void main(String[] args) {
TaskA solver = new TaskA();
int t = in.nextInt();
for (int i = 1; i <= t ; i++) {
solver.solve(i, in, out);
}
// solver.solve(1, in, out);
out.flush();
out.close();
}
static class TaskA {
public void solve(int testNumber, InputReader in, PrintWriter out) {
int n= in.nextInt();
char[]c=new char[n];
int r=in.nextInt();
int b= in.nextInt();
int diff=ceil(r,(b+1));
int i=0;int ct=0;
while(i<n) {
int j=i;
for(j=i;j<i+diff&&j<n;j++) {
c[j]='R';
}
i=j;
if(j<n) {
c[i]='B';i++;ct++;
}
}
ct=b-ct;int ind=0;
while(ct>0) {
if(c[ind]=='R'&&ind+1<n&&c[ind+1]=='B') {
c[ind]='B';ct--;
}
ind++;
}
println(String.valueOf(c));
}
}
static int ceil(int a,int b) {
int ans=a/b;if(a%b!=0) {
ans++;
}
return ans;
}
static int query(int l,int r) {
System.out.println("? "+l+" "+r);
System.out.print ("\n");
int x=in.nextInt();
return x;
}
static boolean check(Pair[]arr,int mid,int n) {
int c=0;
for(int i=0;i<n;i++) {
if(mid-1-arr[i].first<=c&&c<=arr[i].second) {
c++;
}
}
return c>=mid;
}
static long sum(int[]arr) {
long s=0;
for(int x:arr) {
s+=x;
}
return s;
}
static long sum(long[]arr) {
long s=0;
for(long x:arr) {
s+=x;
}
return s;
}
static int gcd(int a, int b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
static void sort(int[] a) {
ArrayList<Integer> q = new ArrayList<>();
for (int i : a) q.add(i);
Collections.sort(q);
for (int i = 0; i < a.length; i++) a[i] = q.get(i);
}
static void sort(long[] a) {
ArrayList<Long> q = new ArrayList<>();
for (long i : a) q.add(i);
Collections.sort(q);
for (int i = 0; i < a.length; i++) a[i] = q.get(i);
}
static void println(int[][]arr) {
for(int i=0;i<arr.length;i++) {
for(int j=0;j<arr[0].length;j++) {
print(arr[i][j]+" ");
}
print("\n");
}
}
static void println(long[][]arr) {
for(int i=0;i<arr.length;i++) {
for(int j=0;j<arr[0].length;j++) {
print(arr[i][j]+" ");
}
print("\n");
}
}
static void println(int[]arr){
for(int i=0;i<arr.length;i++) {
print(arr[i]+" ");
}
print("\n");
}
static void println(long[]arr){
for(int i=0;i<arr.length;i++) {
print(arr[i]+" ");
}
print("\n");
}
static long[]input(int n){
long[]arr=new long[n];
for(int i=0;i<n;i++) {
arr[i]=in.nextInt();
}
return arr;
}
static long[]input(){
long n= in.nextInt();
long[]arr=new long[(int)n];
for(int i=0;i<n;i++) {
arr[i]=in.nextLong();
}
return arr;
}
////////////////////////////////////////////////////////
static class Pair {
long first;
long second;
Pair(long x, long y)
{
this.first = x;
this.second = y;
}
}
static void sortS(Pair arr[])
{
Arrays.sort(arr, new Comparator<Pair>() {
@Override public int compare(Pair p1, Pair p2)
{
return (int)(p1.second - p2.second);
}
});
}
static void sortF(Pair arr[])
{
Arrays.sort(arr, new Comparator<Pair>() {
@Override public int compare(Pair p1, Pair p2)
{
return (int)(p1.first - p2.first);
}
});
}
/////////////////////////////////////////////////////////////
static InputStream inputStream = System.in;
static OutputStream outputStream = System.out;
static InputReader in = new InputReader(inputStream);
static PrintWriter out = new PrintWriter(outputStream);
static void println(long c) {
out.println(c);
}
static void print(long c) {
out.print(c);
}
static void print(int c) {
out.print(c);
}
static void println(int x) {
out.println(x);
}
static void print(String s) {
out.print(s);
}
static void println(String s) {
out.println(s);
}
static void println(boolean b) {
out.println(b);
}
static class InputReader {
public BufferedReader reader;
public StringTokenizer tokenizer;
public InputReader(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | e98a3ba1707de66c24ec233bce3cefc9 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
import javax.lang.model.util.ElementScanner6;
import java.util.*;
public class codeforces
{
public static void main(String[] args) {
Scanner ob = new Scanner(System.in);
int t =ob.nextInt();
while(t-->0)
{
int total = ob.nextInt();
int noR = ob.nextInt();
int noB = ob.nextInt();;
int z = Math.min (noR,noB);
int x = Math.max(noR,noB);;
int q= x/z;
int r = x%(z+1);
String str = "";
if(q==x)
{
x=1+(x/2);
if(x==noB)
{
for (int i = 1; i <=total; i++) {
if(i==x)
str+="R";
else
str += "B";
}
}
else
{
for (int i = 1; i <=total; i++) {
if(i==x)
str+="B";
else
str += "R";
}
}
}
else
{
for(int i=0;i<(noB+1);i++){
for(int j=0;j<noR/(noB+1);j++){
str+="R";
}
if(r>0){
str+="R";
r--;
}
if(i<noB){
str+="B";
}
}
}
System.out.println(str);
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 58b851db35469438cab1094bab731e34 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.lang.*;
public class Solution{
static long mod=(long)1e9+7;
static int mod1=998244353;
static int[] cost=new int[(int)1005];
static FastScanner sc = new FastScanner();
// static StringBuffer ans=new StringBuffer("");
public static void solve(){
int n=sc.nextInt(),r=sc.nextInt(),b=sc.nextInt();
while (b > 0) {
int len = (int) Math.ceil((double) r / (b + 1));
for (int i = 0; i < len; i++) {
System.out.print("R");
}
System.out.print("B");
b--;
r -=len;
}
while (r > 0) {
System.out.print("R");
r--;
}
System.out.println();
}
public static void main(String[] args) {
int t = sc.nextInt();
// int t=1;
outer: for (int tt = 0; tt < t; tt++) {
solve();
}
// System.out.println(ans);
}
static boolean isSubSequence(String str1, String str2,
int m, int n)
{
int j = 0;
for (int i = 0; i < n && j < m; i++)
if (str1.charAt(j) == str2.charAt(i))
j++;
return (j == m);
}
static boolean isPrime(int n)
{
if (n <= 1)
return false;
if (n <= 3)
return true;
if (n % 2 == 0 || n % 3 == 0)
return false;
for (int i = 5; i * i <= n; i = i + 6)
if (n % i == 0 || n % (i + 2) == 0)
return false;
return true;
}
public static int[] LPS(String s){
int[] lps=new int[s.length()];
int i=0,j=1;
while (j<s.length()) {
if(s.charAt(i)==s.charAt(j)){
lps[j]=i+1;
i++;
j++;
continue;
}else{
if (i==0) {
j++;
continue;
}
i=lps[i-1];
while(s.charAt(i)!=s.charAt(j) && i!=0) {
i=lps[i-1];
}
if(s.charAt(i)==s.charAt(j)){
lps[j]=i+1;
i++;
}
j++;
}
}
return lps;
}
static long getPairsCount(int n, double sum,int[] arr)
{
HashMap<Double, Integer> hm = new HashMap<>();
for (int i = 0; i < n; i++) {
if (!hm.containsKey((double)arr[i]))
hm.put((double)arr[i], 0);
hm.put((double)arr[i], hm.get((double)arr[i]) + 1);
}
long twice_count = 0;
for (int i = 0; i < n; i++) {
if (hm.get(sum - arr[i]) != null)
twice_count += hm.get(sum - arr[i]);
if (sum - (double)arr[i] == (double)arr[i])
twice_count--;
}
return twice_count / 2l;
}
static boolean[] sieveOfEratosthenes(int n)
{
boolean prime[] = new boolean[n + 1];
for (int i = 0; i <= n; i++)
prime[i] = true;
for (int p = 2; p * p <= n; p++)
{
if (prime[p] == true)
{
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
prime[1]=false;
return prime;
}
static long power(long x, long y, long p)
{
long res = 1l;
x = x % p;
if (x == 0)
return 0;
while (y > 0)
{
if ((y & 1) != 0)
res = (res * x) % p;
y>>=1;
x = (x * x) % p;
}
return res;
}
public static int log2(int N)
{
int result = (int)(Math.log(N) / Math.log(2));
return result;
}
////////////////////////////////////////////////////////////////////////////////////
////////////////////DO NOT READ AFTER THIS LINE //////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////
static long modFact(int n,
int p)
{
if (n >= p)
return 0;
long result = 1l;
for (int i = 2; i <= n; i++)
result = (result * i) % p;
return result;
}
static boolean isPalindrom(char[] arr, int i, int j) {
boolean ok = true;
while (i <= j) {
if (arr[i] != arr[j]) {
ok = false;
break;
}
i++;
j--;
}
return ok;
}
static int max(int a, int b) {
return Math.max(a, b);
}
static int min(int a, int b) {
return Math.min(a, b);
}
static long max(long a, long b) {
return Math.max(a, b);
}
static long min(long a, long b) {
return Math.min(a, b);
}
static int abs(int a) {
return Math.abs(a);
}
static long abs(long a) {
return Math.abs(a);
}
static void swap(long arr[], int i, int j) {
long temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
static void swap(int arr[], int i, int j) {
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
static int maxArr(int arr[]) {
int maxi = Integer.MIN_VALUE;
for (int x : arr)
maxi = max(maxi, x);
return maxi;
}
static int minArr(int arr[]) {
int mini = Integer.MAX_VALUE;
for (int x : arr)
mini = min(mini, x);
return mini;
}
static long maxArr(long arr[]) {
long maxi = Long.MIN_VALUE;
for (long x : arr)
maxi = max(maxi, x);
return maxi;
}
static long minArr(long arr[]) {
long mini = Long.MAX_VALUE;
for (long x : arr)
mini = min(mini, x);
return mini;
}
static int lcm(int a,int b){
return (int)(((long)a*b)/(long)gcd(a,b));
}
static int gcd(int a, int b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
static long gcd(long a, long b) {
if (b == 0)
return a;
return gcd(b, a % b);
}
static void ruffleSort(int[] a) {
int n = a.length;
Random r = new Random();
for (int i = 0; i < a.length; i++) {
int oi = r.nextInt(n);
int temp = a[i];
a[i] = a[oi];
a[oi] = temp;
}
Arrays.sort(a);
}
public static int binarySearch(int a[], int target) {
int left = 0;
int right = a.length - 1;
int mid = (left + right) / 2;
int i = 0;
while (left <= right) {
if (a[mid] <= target) {
i = mid + 1;
left = mid + 1;
} else {
right = mid - 1;
}
mid = (left + right) / 2;
}
return i-1;
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
long[] readLongArray(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
int[][] read2dArray(int n, int m) {
int arr[][] = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
arr[i][j] = nextInt();
}
}
return arr;
}
ArrayList<Integer> readArrayList(int n) {
ArrayList<Integer> arr = new ArrayList<Integer>();
for (int i = 0; i < n; i++) {
int a = nextInt();
arr.add(a);
}
return arr;
}
long nextLong() {
return Long.parseLong(next());
}
}
static class Pair {
int val;
long coins;
Pair(int val,long coins) {
this.val=val;
this.coins=coins;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 0d5867a6673675c78e1eb49c5ed5d223 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class A {
static MyScanner sc;
static PrintWriter out;
static {
sc = new MyScanner();
out = new PrintWriter(System.out);
}
public static void solve() {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
int g = b + 1;
int[] a = new int[g];
for(int i = 0; i < r; i++) {
a[i % g]++;
}
for(int i = 0; i < g - 1; i++) {
for(int j = 0; j < a[i]; j++)
out.print("R");
out.print("B");
}
for(int i = 0; i < a[g - 1]; i++)
out.print("R");
out.println();
}
public static void main(String[] args) {
int t = sc.nextInt();
while(t-- > 0)
solve();
out.flush();
}
}
class MyScanner {
BufferedReader br;
StringTokenizer tok;
MyScanner() {
try { br = new BufferedReader(new InputStreamReader(System.in)); }
catch(Exception e) { System.out.println(e); }
tok = new StringTokenizer("");
}
public String next() {
try {
while(!tok.hasMoreTokens()) tok = new StringTokenizer(br.readLine());
}
catch(Exception e) { System.out.println(e); }
return tok.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 8d70475782d648159d4608c3124c9c8e | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class Hey {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
String result = getResults(n, r, b);
System.out.println(result);
}
}
private static String getResults(int n, int r, int b) {
StringBuilder resultSB = new StringBuilder();
setResults(resultSB, r, b);
return resultSB.toString();
}
private static void setResults(StringBuilder resultSB, int r, int b) {
if (r + b == 0) {
return;
}
int take = LIG(r, b + 1);
r -= take;
for (int i = 0; i < take; i++) {
resultSB.append('R');
}
if (b > 0) {
resultSB.append('B');
b--;
}
setResults(resultSB, r, b);
}
private static int LIG(int numerator, int denominator) {
return (numerator + denominator - 1) / denominator;
}
public static void sort(int[] arr) {
ArrayList<Integer> l = new ArrayList<>();
for (int i : arr) l.add(i);
Collections.sort(l);
for (int i = 0; i < arr.length; i++) {
arr[i] = l.get(i);
}
}
public static class Pair implements Comparable<Pair> {
int x, y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
public int compareTo(Pair A) {
return this.y > A.y ? -1 : 1; // sorting ascending
}
@Override
public String toString() {
return "{" + x + "," + y + '}';
}
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public boolean ready() throws IOException {
return br.ready();
}
public int[] nextIntArr(int n) throws IOException {
int[] arr = new int[n];
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(next());
}
return arr;
}
public long[] nextLongArr(int n) throws IOException {
long[] arr = new long[n];
for (int i = 0; i < n; i++) {
arr[i] = Integer.parseInt(next());
}
return arr;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 98f4db61ed28a4c5073d1f450ff1cfdf | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static class Pair implements Comparable<Pair> {
int a, b;
Pair(int a, int b) {
this.a = a;
this.b = b;
}
public int compareTo(Pair o) {
return this.a - o.a;
}
}
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
// InputStreamReader r = new InputStreamReader(System.in);
// BufferedReader br = new BufferedReader(r);
FastReader scn = new FastReader();
BufferedWriter output = new BufferedWriter(new OutputStreamWriter(System.out));
int t = scn.nextInt();
while (t-- > 0) {
int n = scn.nextInt();
int r = scn.nextInt();
int b = scn.nextInt();
StringBuilder sb = new StringBuilder();
while (b > 0) {
int x = (int) Math.ceil(r * 1.0 / (b + 1));
while (x-- > 0 && r > 0) {
sb.append("R");
r--;
}
sb.append("B");
b--;
}
while (r-- > 0)
sb.append("R");
output.write(sb + "\n");
output.flush();
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | e9a291b5f501104c5d4816259105bc2e | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | // package div_2_782;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
public class A{
public static void main(String[] args){
FastReader sc = new FastReader();
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
int pos=(r+1)/(b+1);
String s="";
while(r>0) {
for(int i=0;i<pos && i<r;i++)s+='R';
r-=pos;
if(b<=0)break;
s+='B';
b--;
}
String temp="";
for(int i=0;i<s.length();i++) {
if(s.charAt(i)=='B' && r>0) {
temp+='R';
temp+='B';
r--;
}else temp+=s.charAt(i);
}
System.out.println(temp);
}
}
static int pow(int a,int b) {
if(b==0)return 1;
if(b==1)return a;
return a*pow(a,b-1);
}
static class pair {
int x;int y;
pair(int x,int y){
this.x=x;
this.y=y;
}
}
static ArrayList<Integer> primeFac(int n){
ArrayList<Integer>ans = new ArrayList<Integer>();
int lp[]=new int [n+1];
Arrays.fill(lp, 0); //0-prime
for(int i=2;i<=n;i++) {
if(lp[i]==0) {
for(int j=i;j<=n;j+=i) {
if(lp[j]==0) lp[j]=i;
}
}
}
int fac=n;
while(fac>1) {
ans.add(lp[fac]);
fac=fac/lp[fac];
}
print(ans);
return ans;
}
static ArrayList<Long> prime_in_given_range(long l,long r){
ArrayList<Long> ans= new ArrayList<>();
int n=(int)Math.sqrt(r)+1;
int prime[]=sieve_of_Eratosthenes(n);
long res[]=new long [(int)(r-l)+1];
for(int i=0;i<=r-l;i++) {
res[i]=i+l;
}
for(int i=0;i<prime.length;i++) {
if(prime[i]==1) {
System.out.println(2);
for(int j=Math.max((int)i*i, (int)(l+i-1)/i*i);j<=r;j+=i) {
res[j-(int)l]=0;
}
}
}
for(long i:res) if(i!=0)ans.add(i);
return ans;
}
static int [] sieve_of_Eratosthenes(int n) {
int prime[]=new int [n];
Arrays.fill(prime, 1); // 1-prime | 0-not prime
prime[0]=prime[1]=0;
for(int i=2;i<n;i++) {
if(prime[i]==1) {
for(int j=i*i;j<n;j+=i) {
prime[j]=0;
}
}
}
return prime;
}
static long binpow(long a,long b) {
long res=1;
if(b==0)return 1;
if(a==0)return 0;
while(b>0) {
if((b&1)==1) {
res*=a;
}
a*=a;
b>>=1;
}
return res;
}
static void print(int a[]) {
System.out.println(a.length);
for(int i:a) {
System.out.print(i+" ");
}
System.out.println();
}
static void print(long a[]) {
System.out.println(a.length);
for(long i:a) {
System.out.print(i+" ");
}
System.out.println();
}
static long rolling_hashcode(String s ,int st,int end,long Hashcode,int n) {
if(end>=s.length()) return -1;
int mod=1000000007;
Hashcode=Hashcode-(s.charAt(st-1)*(long)Math.pow(27,n-1));
Hashcode*=10;
Hashcode=(Hashcode+(long)s.charAt(end))%mod;
return Hashcode;
}
static long hashcode(String s,int n) {
long code=0;
for(int i=0;i<n;i++) {
code+=((long)s.charAt(i)*(long)Math.pow(27, n-i-1)%1000000007);
}
return code;
}
static void print(ArrayList<Integer> a) {
System.out.println(a.size());
for(long i:a) {
System.out.print(i+" ");
}
System.out.println();
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
int [] fastArray(int n) {
int a[]=new int [n];
for(int i=0;i<n;i++) {
a[i]=nextInt();
}
return a;
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 650e47c8fb9dbb30902103463f694cd9 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution1 {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader()
{
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException
{
din = new DataInputStream(
new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException
{
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
if (cnt != 0) {
break;
}
else {
continue;
}
}
buf[cnt++] = (byte)c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException
{
int ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException
{
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException
{
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException
{
bytesRead = din.read(buffer, bufferPointer = 0,
BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException
{
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException
{
if (din == null)
return;
din.close();
}
}
public static String f(int n,int r,int b) {
int t=r/(b+1);
int extra=0;
if((r%(b+1))!=0) {
extra=(r%(b+1));
}
boolean gap=false;
int i=0;
String ans="";
while(i<n) {
if(!gap && r>0) {
if(b==0) {
for(;r>0;r--) {
ans+="R";
i++;
}
}else {
for(int j=0;j<t && r>0;j++) {
ans+="R";
i++;
r--;
}
}
}else {
if(extra!=0) {
ans+="R";
extra--;
i++;
r--;
}
ans+="B";
b--;
i++;
}
gap=!gap;
}
return ans;
}
public static String g(int n,int r, int b) {
if(b==1) {
int mid=n/2;
String ans="";
for(int i=0;i<n;i++) {
if(i==mid) {
ans+="B";
}else {
ans+="R";
}
}
return ans;
}
int t=r/b;
String repeat="";
for(int i=0;i<t;i++) {
repeat+="R";
}
repeat+="B";
//System.out.println(repeat);
String ans="";
while(r>0) {
if(b==0) {
for(;r>0;r--) {
ans+="R";
}
}else {
ans+=repeat;
r-=t;
b--;
}
}
return ans;
}
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
FastReader s=new FastReader();
//Reader s=new Reader();
int t=s.nextInt();
for(int i=0;i<t;i++) {
int n=s.nextInt();
int r=s.nextInt();
int b=s.nextInt();
System.out.println(f(n,r,b));
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 66981f53f73b3cbeeb16dc20de6a7c03 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes |
import java.util.Scanner;
public class CodeForce {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-->0){
int n = s.nextInt();
int r = s.nextInt();
int b = s.nextInt();
String[] arr = new String[b];
for(int i = 0;i < b; i++){
arr[i] = "RB";
}
arr[b-1]+="R";
r-= (b+1);
while(r > 0){
for(int i = 0;i < b && r > 0; i++){
arr[i] = "R"+arr[i];
r--;
}
if(r>0) {
arr[b-1]+="R";
r--;
}
}
for(String val: arr){
System.out.print(val);
}
System.out.println();
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | a6e49ac85aeb6bcfa7cedc92995a5806 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static StringTokenizer st;
static Scanner sc = new Scanner(System.in);
public static void main(String[] args) throws IOException {
int t = readInt();
for(int i=0; i<t; i++) {
int n = readInt();
int r = readInt();
int b = readInt();
int div = (int) Math.ceil((double)r/(b+1));
String result = "";
while(r>b && r>0) {
int a = Math.min(r, div);
result += "R".repeat(a);
r-=a;
if(b>r) {
result += "B".repeat(b-r);
b -= b-r;
}
else if(b>0) {
result += "B";
b--;
}
}
result += "RB".repeat(r);
System.out.println(result);
}
}
static String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine().trim());
return st.nextToken();
}
static long readLong() throws IOException {
return Long.parseLong(next());
}
static int readInt() throws IOException {
return Integer.parseInt(next());
}
static double readDouble() throws IOException {
return Double.parseDouble(next());
}
static char readCharacter() throws IOException {
return next().charAt(0);
}
static String readLine() throws IOException {
return br.readLine().trim();
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | d38f7c1908f9c7bc622a96929236b9d5 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class RedVersusBlue {
public static void redBlue(int n, int r, int b) {
char arr[] = new char[n];
double posB = (double)r/(b+1);
double move = posB;
for(int i = 0; i<b; i++) {
arr[(int)(move + i)] = 'B';
move = move + posB;
}
for(int i = 0; i<n; i++) {
if(arr[i] != 'B') {
arr[i] = 'R';
}
}
// String str = Arrays.toString(arr);
String str = "";
for(int i = 0; i<arr.length; i++) {
str = str + arr[i];
}
System.out.println(str);
}
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
for(int i = 0; i<t; i++) {
int n = s.nextInt();
int r = s.nextInt();
int b = s.nextInt();
redBlue(n,r,b);
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | cfcdd8070b5858fb1b776da696befda6 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class CodeForces {
/*-------------------------------------------EDITING CODE STARTS HERE-------------------------------------------*/
public static void solve(int tCase) throws IOException {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
String[] str = new String[b];
for(int i=0;i<b;i++)str[i] = "B";
int j = 0;
for(int i=0;i<r;i++){
if(j==b){
str[b-1] += "R";
j=0;
}else {
str[j] = "R" + str[j];
j++;
}
}
for(String x : str)out.print(x);
out.println();
}
public static void main(String[] args) throws IOException {
openIO();
int testCase = 1;
testCase = sc.nextInt();
for (int i = 1; i <= testCase; i++) solve(i);
closeIO();
}
/*-------------------------------------------EDITING CODE ENDS HERE-------------------------------------------*/
/*--------------------------------------HELPER FUNCTIONS STARTS HERE-----------------------------------------*/
// public static int mod = (int) 1e9 + 7;
public static int mod = 998244353;
public static int inf_int = (int) 2e9+10;
public static long inf_long = (long) 2e18;
public static void _sort(int[] arr, boolean isAscending) {
int n = arr.length;
List<Integer> list = new ArrayList<>();
for (int ele : arr) list.add(ele);
Collections.sort(list);
if (!isAscending) Collections.reverse(list);
for (int i = 0; i < n; i++) arr[i] = list.get(i);
}
public static void _sort(long[] arr, boolean isAscending) {
int n = arr.length;
List<Long> list = new ArrayList<>();
for (long ele : arr) list.add(ele);
Collections.sort(list);
if (!isAscending) Collections.reverse(list);
for (int i = 0; i < n; i++) arr[i] = list.get(i);
}
// time : O(1), space : O(1)
public static int _digitCount(long num,int base){
// this will give the # of digits needed for a number num in format : base
return (int)(1 + Math.log(num)/Math.log(base));
}
// time : O(n), space: O(n)
public static long _fact(int n){
// simple factorial calculator
long ans = 1;
for(int i=2;i<=n;i++)
ans = ans * i % mod;
return ans;
}
// time for pre-computation of factorial and inverse-factorial table : O(nlog(mod))
public static long[] factorial , inverseFact;
public static void _ncr_precompute(int n){
factorial = new long[n+1];
inverseFact = new long[n+1];
factorial[0] = inverseFact[0] = 1;
for (int i = 1; i <=n; i++) {
factorial[i] = (factorial[i - 1] * i) % mod;
inverseFact[i] = _modExpo(factorial[i], mod - 2);
}
}
// time of factorial calculation after pre-computation is O(1)
public static int _ncr(int n,int r){
if(r > n)return 0;
return (int)(factorial[n] * inverseFact[r] % mod * inverseFact[n - r] % mod);
}
public static int _npr(int n,int r){
if(r > n)return 0;
return (int)(factorial[n] * inverseFact[n - r] % mod);
}
// euclidean algorithm time O(max (loga ,logb))
public static long _gcd(long a, long b) {
while (a>0){
long x = a;
a = b % a;
b = x;
}
return b;
// if (a == 0)
// return b;
// return _gcd(b % a, a);
}
// lcm(a,b) * gcd(a,b) = a * b
public static long _lcm(long a, long b) {
return (a / _gcd(a, b)) * b;
}
// binary exponentiation time O(logn)
public static long _modExpo(long x, long n) {
long ans = 1;
while (n > 0) {
if ((n & 1) == 1) {
ans *= x;
ans %= mod;
n--;
} else {
x *= x;
x %= mod;
n >>= 1;
}
}
return ans;
}
// function to find a/b under modulo mod. time : O(logn)
public static long _modInv(long a,long b){
return (a * _modExpo(b,mod-2)) % mod;
}
//sieve or first divisor time : O(mx * log ( log (mx) ) )
public static int[] _seive(int mx){
int[] firstDivisor = new int[mx+1];
for(int i=0;i<=mx;i++)firstDivisor[i] = i;
for(int i=2;i*i<=mx;i++)
if(firstDivisor[i] == i)
for(int j = i*i;j<=mx;j+=i)
if(firstDivisor[j]==j)firstDivisor[j] = i;
return firstDivisor;
}
// check if x is a prime # of not. time : O( n ^ 1/2 )
private static boolean _isPrime(long x){
for(long i=2;i*i<=x;i++)
if(x%i==0)return false;
return true;
}
static class Pair<K, V>{
K ff;
V ss;
public Pair(K ff, V ss) {
this.ff = ff;
this.ss = ss;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || this.getClass() != o.getClass()) return false;
Pair<?, ?> pair = (Pair<?, ?>) o;
return ff.equals(pair.ff) && ss.equals(pair.ss);
}
@Override
public int hashCode() {
return Objects.hash(ff, ss);
}
@Override
public String toString(){
return ff.toString()+" "+ss.toString();
}
}
/*--------------------------------------HELPER FUNCTIONS ENDS HERE-----------------------------------------*/
/*-------------------------------------------FAST INPUT STARTS HERE---------------------------------------------*/
static FastestReader sc;
static PrintWriter out;
private static void openIO() throws IOException {
sc = new FastestReader();
out = new PrintWriter(System.out);
}
public static void closeIO() throws IOException {
out.flush();
out.close();
sc.close();
}
private static final class FastestReader {
private static final int BUFFER_SIZE = 1 << 16;
private final DataInputStream din;
private final byte[] buffer;
private int bufferPointer, bytesRead;
public FastestReader() {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public FastestReader(String file_name) throws IOException {
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
private static boolean isSpaceChar(int c) {
return !(c >= 33 && c <= 126);
}
private int skip() throws IOException {
int b;
//noinspection StatementWithEmptyBody
while ((b = read()) != -1 && isSpaceChar(b)) {}
return b;
}
public String next() throws IOException {
int b = skip();
final StringBuilder sb = new StringBuilder();
while (!isSpaceChar(b)) { // when nextLine, (isSpaceChar(b) && b != ' ')
sb.appendCodePoint(b);
b = read();
}
return sb.toString();
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ') c = read();
final boolean neg = c == '-';
if (neg) c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
return neg?-ret:ret;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ') c = read();
final boolean neg = c == '-';
if (neg) c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
return neg?-ret:ret;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ') c = read();
final boolean neg = c == '-';
if (neg) c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (c == '.')
while ((c = read()) >= '0' && c <= '9')
ret += (c - '0') / (div *= 10);
return neg?-ret:ret;
}
public String nextLine() throws IOException {
final byte[] buf = new byte[(1<<10)]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
break;
}
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1) buffer[0] = -1;
}
private byte read() throws IOException {
if (bufferPointer == bytesRead) fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException {
din.close();
}
}
/*---------------------------------------------FAST INPUT ENDS HERE ---------------------------------------------*/
}
/** Some points to keep in mind :
* 1. don't use Arrays.sort(primitive data type array)
* 2. try to make the parameters of a recursive function as less as possible,
* more use static variables.
*
**/ | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 8c7ce902ae85da42d939a284fd229056 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes |
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
q1();
}
public static void q1() {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
while (t-->0) {
int n = in.nextInt(), r = in.nextInt(), b = in.nextInt();
char[] ans = new char[n];
int cnt = (int) Math.ceil(r*1.0/(b+1));
for (int i=0;i<n;i++) {
if (cnt == 0) {
ans[i] = 'B';
b--;
cnt = (int) Math.ceil(r*1.0/(b+1));
}else{
ans[i] = 'R';
r--;
cnt--;
}
}
System.out.println(String.valueOf(ans));
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | b24624fce8b77f4dff3b5ec0dcfce2a2 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static FastReader in=new FastReader();
static final Random random=new Random();
public static void main(String args[]) throws IOException {
int t=in.nextInt();
while(t-->0){
int arr[]=in.readintarray(3);
int n=arr[0];
int r=arr[1];
int b=arr[2];
String str="";
while(r!=0 && b!=0){
int t1=r/(b+1);
for(int i=0;i<t1;i++){
str+="R";
}
str+="B";
r-=t1;
b-=1;
}
int z=n-str.length();
for(int i=0;i<z;i++)str+="R";
print(str);
}
}
static int max(int a, int b)
{
if(a<b)
return b;
return a;
}
static void ruffleSort(int[] a) {
int n=a.length;
for (int i=0; i<n; i++) {
int oi=random.nextInt(n), temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static < E > void print(E res)
{
System.out.println(res);
}
static int gcd(int a,int b)
{
if(b==0)
{
return a;
}
return gcd(b,a%b);
}
static int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
static int abs(int a)
{
if(a<0)
return -1*a;
return a;
}
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new
InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
int [] readintarray(int n) {
int res [] = new int [n];
for(int i = 0; i<n; i++)res[i] = nextInt();
return res;
}
long [] readlongarray(int n) {
long res [] = new long [n];
for(int i = 0; i<n; i++)res[i] = nextLong();
return res;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | c38505f544555d78d70d517dcfbf24e5 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class c3{
static class Pair{
int first;
int last;
public Pair(int first , int last){
this.first = first;
this.last = last;
}
public int getFirst(){
return first;
}
public int getLast(){
return last;
}
}
static final int M = 1000000007;
// Fast input
static class Hrittik_FastReader{
StringTokenizer st;
BufferedReader br;
public int n;
public Hrittik_FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while(st==null || !st.hasMoreTokens()){
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
String nextLine(){
String str="";
try {
str=br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
double nextDouble(){
return Double.parseDouble(next());
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong(){
return Long.parseLong(next());
}
}
// Fast output
static class Hrittik_FastWriter {
private final BufferedWriter bw;
public Hrittik_FastWriter() {
this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
public void println(Object object) throws IOException {
print(object);
bw.append("\n");
}
public void print(Object object) throws IOException {
bw.append("" + object);
}
public void close() throws IOException {
bw.close();
}
}
// GCD of two integers
private static int gcd(int a , int b){
if(b == 0) return a;
return gcd(b, a%b);
}
// GCD of two long integers
private static long gcd(long a , long b){
if(b == 0) return a;
return gcd(b, a%b);
}
// LCM of two integers
private static int lcm(int a, int b) {
return a / gcd(a, b) * b;
}
// LCM of two long integers
private static long lcm(long a, long b) {
return a / gcd(a, b) * b;
}
// swap two elements of an array
private static void swap(int[] arr, int i, int j){
int temp = arr[i];
arr[i] = arr[j];
arr[j] = temp;
}
// calculating x ^ y
private static long power(long x, long y){
long res = 1;
x = x % M;
while(y > 0){
if ((y & 1) == 1){
res = (res * x) % M;
}
y = y >> 1;
x = (x * x) % M;
}
return res;
}
static void sortPairByFirst(Pair arr[]){
Arrays.sort(arr , new Comparator<Pair>(){
@Override public int compare(Pair p1 , Pair p2){
return p1.first - p2.first;
}
});
}
static void sortPairByLast(Pair arr[]){
Arrays.sort(arr , new Comparator<Pair>(){
@Override public int compare(Pair p1 , Pair p2){
return p1.last - p2.last;
}
});
}
public static void main(String[] args) {
try {
Hrittik_FastReader Sc =new Hrittik_FastReader();
Hrittik_FastWriter out = new Hrittik_FastWriter();
int t = Sc.nextInt();
outer : while(t-- > 0){
// write your code here
int n = Sc.nextInt();
int r = Sc.nextInt();
int b = Sc.nextInt();
//int x = (int) Math.ceil((double)r / (double)(b+1));
int x = r / (b+1);
int g = r % (b+1);
char a[] = new char[n];
Arrays.fill(a , 'R');
for(int i = x; i < n; i+=x+1){
if(g > 0){
i++;
g--;
a[i] = 'B';
}
else{
a[i] = 'B';
}
}
// String ans = "";
// while(b > 0 && r > 0){
// for(int i = 1; i <= x; i++){
// ans += 'R';
// r--;
// }
// ans += 'B';
// b--;
// }
// if(r > 0){
// for(int i = 0; i < r; i++){
// ans += 'R';
// r--;
// }
// }
// int i = 0;
// while(i < n){
// int j = 0;
// if(i > n)break;
// while(j < x){
// ans+='R';
// i++;
// if(i > 1) break;
// }
// if(i > n)break;
// ans+='B';
// i++;
// r-=x;
// if(i > n)break;
// b-=1;
// }
for(int i = 0; i < n; i++){
System.out.print(a[i]);
}
System.out.println();
}
out.close();
}
catch (Exception e) {
return;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | f36ac94a68a62c6d8db0b9c4b545a013 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.math.BigInteger;
import java.io.*;
public class Main implements Runnable {
public static void main(String[] args) {
new Thread(null, new Main(), "whatever", 1 << 26).start();
}
private FastScanner sc;
private PrintWriter pw;
public void run() {
try {
boolean isSumitting = true;
// isSumitting = false;
if (isSumitting) {
pw = new PrintWriter(System.out);
sc = new FastScanner(new BufferedReader(new InputStreamReader(System.in)));
} else {
pw = new PrintWriter(new BufferedWriter(new FileWriter("output.txt")));
sc = new FastScanner(new BufferedReader(new FileReader("input.txt")));
}
} catch (Exception e) {
throw new RuntimeException();
}
int t = sc.nextInt();
// int t = 1;
while (t-- > 0) {
// sc.nextLine();
// System.out.println("for t=" + t);
solve();
}
pw.close();
}
public long mod = 1_000_000_007;
private class Pair {
int first, second;
Pair(int first, int second) {
this.first = first;
this.second = second;
}
}
private void solve() {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
helper(n, r, b);
pw.println();
}
private void helper(int n, int r, int b) {
int div = (int)Math.ceil(((double)r) / (b + 1));
for (int i = 0; i < div; i++) {
pw.print("R");
}
if (b > 0) {
pw.print("B");
}
if (r - div > 0)
helper(n, r - div, b - 1);
}
class FastScanner {
private BufferedReader reader = null;
private StringTokenizer tokenizer = null;
public FastScanner(BufferedReader bf) {
reader = bf;
tokenizer = null;
}
public String next() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public String nextLine() {
if (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
return reader.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken("\n");
}
public long nextLong() {
return Long.parseLong(next());
}
public int nextInt() {
return Integer.parseInt(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
public float nextFloat() {
return Float.parseFloat(next());
}
public int[] nextIntArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) {
a[i] = nextInt();
}
return a;
}
public String[] nextStringArray(int n) {
String[] a = new String[n];
for (int i = 0; i < n; i++) {
a[i] = next();
}
return a;
}
public long[] nextLongArray(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++) {
a[i] = nextLong();
}
return a;
}
}
private static class Sorter {
public static <T extends Comparable<? super T>> void sort(T[] arr) {
Arrays.sort(arr);
}
public static <T> void sort(T[] arr, Comparator<T> c) {
Arrays.sort(arr, c);
}
public static <T> void sort(T[][] arr, Comparator<T[]> c) {
Arrays.sort(arr, c);
}
public static <T extends Comparable<? super T>> void sort(ArrayList<T> arr) {
Collections.sort(arr);
}
public static <T> void sort(ArrayList<T> arr, Comparator<T> c) {
Collections.sort(arr, c);
}
public static void normalSort(int[] arr) {
Arrays.sort(arr);
}
public static void normalSort(long[] arr) {
Arrays.sort(arr);
}
public static void sort(int[] arr) {
timSort(arr);
}
public static void sort(int[] arr, Comparator<Integer> c) {
timSort(arr, c);
}
public static void sort(int[][] arr, Comparator<Integer[]> c) {
timSort(arr, c);
}
public static void sort(long[] arr) {
timSort(arr);
}
public static void sort(long[] arr, Comparator<Long> c) {
timSort(arr, c);
}
public static void sort(long[][] arr, Comparator<Long[]> c) {
timSort(arr, c);
}
private static void timSort(int[] arr) {
Integer[] temp = new Integer[arr.length];
for (int i = 0; i < arr.length; i++) temp[i] = arr[i];
Arrays.sort(temp);
for (int i = 0; i < arr.length; i++) arr[i] = temp[i];
}
private static void timSort(int[] arr, Comparator<Integer> c) {
Integer[] temp = new Integer[arr.length];
for (int i = 0; i < arr.length; i++) temp[i] = arr[i];
Arrays.sort(temp, c);
for (int i = 0; i < arr.length; i++) arr[i] = temp[i];
}
private static void timSort(int[][] arr, Comparator<Integer[]> c) {
Integer[][] temp = new Integer[arr.length][arr[0].length];
for (int i = 0; i < arr.length; i++)
for (int j = 0; j < arr[0].length; j++)
temp[i][j] = arr[i][j];
Arrays.sort(temp, c);
for (int i = 0; i < arr.length; i++)
for (int j = 0; j < arr[0].length; j++)
temp[i][j] = arr[i][j];
}
private static void timSort(long[] arr) {
Long[] temp = new Long[arr.length];
for (int i = 0; i < arr.length; i++) temp[i] = arr[i];
Arrays.sort(temp);
for (int i = 0; i < arr.length; i++) arr[i] = temp[i];
}
private static void timSort(long[] arr, Comparator<Long> c) {
Long[] temp = new Long[arr.length];
for (int i = 0; i < arr.length; i++) temp[i] = arr[i];
Arrays.sort(temp, c);
for (int i = 0; i < arr.length; i++) arr[i] = temp[i];
}
private static void timSort(long[][] arr, Comparator<Long[]> c) {
Long[][] temp = new Long[arr.length][arr[0].length];
for (int i = 0; i < arr.length; i++)
for (int j = 0; j < arr[0].length; j++)
temp[i][j] = arr[i][j];
Arrays.sort(temp, c);
for (int i = 0; i < arr.length; i++)
for (int j = 0; j < arr[0].length; j++)
temp[i][j] = arr[i][j];
}
}
public long fastPow(long x, long y, long mod) {
if (y == 0) return 1;
if (y == 1) return x % mod;
long temp = fastPow(x, y / 2, mod);
long ans = (temp * temp) % mod;
return (y % 2 == 1) ? (ans * (x % mod)) % mod : ans;
}
public long fastPow(long x, long y) {
if (y == 0) return 1;
if (y == 1) return x;
long temp = fastPow(x, y / 2);
long ans = (temp * temp);
return (y % 2 == 1) ? (ans * x) : ans;
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 4239c2e89c9d7886712e872a4c54ab59 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class A {
static class Scan {
private byte[] buf=new byte[1024];
private int index;
private InputStream in;
private int total;
public Scan()
{
in=System.in;
}
public int scan()throws IOException
{
if(total<0)
throw new InputMismatchException();
if(index>=total)
{
index=0;
total=in.read(buf);
if(total<=0)
return -1;
}
return buf[index++];
}
public int scanInt()throws IOException
{
int integer=0;
int n=scan();
while(isWhiteSpace(n))
n=scan();
int neg=1;
if(n=='-')
{
neg=-1;
n=scan();
}
while(!isWhiteSpace(n))
{
if(n>='0'&&n<='9')
{
integer*=10;
integer+=n-'0';
n=scan();
}
else throw new InputMismatchException();
}
return neg*integer;
}
public double scanDouble()throws IOException
{
double doub=0;
int n=scan();
while(isWhiteSpace(n))
n=scan();
int neg=1;
if(n=='-')
{
neg=-1;
n=scan();
}
while(!isWhiteSpace(n)&&n!='.')
{
if(n>='0'&&n<='9')
{
doub*=10;
doub+=n-'0';
n=scan();
}
else throw new InputMismatchException();
}
if(n=='.')
{
n=scan();
double temp=1;
while(!isWhiteSpace(n))
{
if(n>='0'&&n<='9')
{
temp/=10;
doub+=(n-'0')*temp;
n=scan();
}
else throw new InputMismatchException();
}
}
return doub*neg;
}
public String scanString()throws IOException
{
StringBuilder sb=new StringBuilder();
int n=scan();
while(isWhiteSpace(n))
n=scan();
while(!isWhiteSpace(n))
{
sb.append((char)n);
n=scan();
}
return sb.toString();
}
private boolean isWhiteSpace(int n)
{
if(n==' '||n=='\n'||n=='\r'||n=='\t'||n==-1)
return true;
return false;
}
}
public static void sort(int arr[],int l,int r) { //sort(arr,0,n-1);
if(l==r) {
return;
}
int mid=(l+r)/2;
sort(arr,l,mid);
sort(arr,mid+1,r);
merge(arr,l,mid,mid+1,r);
}
public static void merge(int arr[],int l1,int r1,int l2,int r2) {
int tmp[]=new int[r2-l1+1];
int indx1=l1,indx2=l2;
//sorting the two halves using a tmp array
for(int i=0;i<tmp.length;i++) {
if(indx1>r1) {
tmp[i]=arr[indx2];
indx2++;
continue;
}
if(indx2>r2) {
tmp[i]=arr[indx1];
indx1++;
continue;
}
if(arr[indx1]<arr[indx2]) {
tmp[i]=arr[indx1];
indx1++;
continue;
}
tmp[i]=arr[indx2];
indx2++;
}
//Copying the elements of tmp into the main array
for(int i=0,j=l1;i<tmp.length;i++,j++) {
arr[j]=tmp[i];
}
}
public static void sort(long arr[],int l,int r) { //sort(arr,0,n-1);
if(l==r) {
return;
}
int mid=(l+r)/2;
sort(arr,l,mid);
sort(arr,mid+1,r);
merge(arr,l,mid,mid+1,r);
}
public static void merge(long arr[],int l1,int r1,int l2,int r2) {
long tmp[]=new long[r2-l1+1];
int indx1=l1,indx2=l2;
//sorting the two halves using a tmp array
for(int i=0;i<tmp.length;i++) {
if(indx1>r1) {
tmp[i]=arr[indx2];
indx2++;
continue;
}
if(indx2>r2) {
tmp[i]=arr[indx1];
indx1++;
continue;
}
if(arr[indx1]<arr[indx2]) {
tmp[i]=arr[indx1];
indx1++;
continue;
}
tmp[i]=arr[indx2];
indx2++;
}
//Copying the elements of tmp into the main array
for(int i=0,j=l1;i<tmp.length;i++,j++) {
arr[j]=tmp[i];
}
}
public static void main(String args[]) throws IOException {
Scan input=new Scan();
StringBuilder ans=new StringBuilder("");
int test=input.scanInt();
for(int tt=1;tt<=test;tt++) {
int n=input.scanInt();
int r=input.scanInt();
int b=input.scanInt();
int step=(r/(b+1));
step++;
StringBuilder tmp=new StringBuilder("");
for(int i=0,j=1;i<n;i++,j++) {
if(j%step==0 && b>0) {
tmp.append("B");
b--;
}
else if(r>0){
tmp.append("R");
r--;
}
else {
if(b>0) {
tmp.append("B");
}
else {
tmp.append("R");
}
}
}
int cnt=0;
for(int i=tmp.length()-1;i>=0;i--) {
if(tmp.charAt(i)=='R') {
cnt++;
}
else {
break;
}
}
if(cnt>(step-1)) {
int b_count=1;
for(int i=0;i<n;i++) {
if(cnt<=(step-1)) {
break;
}
tmp.deleteCharAt(tmp.length()-1);
int cc=0;
for(int j=0;j<tmp.length();j++) {
if(tmp.charAt(j)=='B') {
cc++;
}
if(cc==b_count) {
tmp.insert(j, "R");
break;
}
}
b_count++;
cnt--;
}
}
ans.append(tmp+"\n");
}
System.out.println(ans);
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | b4db06e14a7f9bd0299ebdd5e361fe43 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes |
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Solution {
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int cas = scan.nextInt();
while(cas-->0){
int n = scan.nextInt();
int r = scan.nextInt();
int b = scan.nextInt();
int nbR = r/(b+1);
String str = buildNbR(nbR);
List<String> list = new ArrayList<>();
for(int i=0; i<b; i++){
list.add(str + "B");
r-=nbR;
}
list.add(str); r-=nbR;
// System.out.println(list);
// System.out.println(r);
StringBuilder sb = new StringBuilder();
int index = 0;
while(index<list.size()){
if (r>0) sb.append("R");
sb.append(list.get(index));
r--; index++;
}
System.out.println(sb.toString());
// System.out.println(sb.toString().length());
}
}
private static String buildNbR(int nbR) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < nbR; i++) {
sb.append("R");
}
return sb.toString();
}
}
/*
* b=1 r=2 rbr
* b=1 r=3 rbrr
* b=1 r=4 rrbrr
*
* */ | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 9947b1055aba26c4a75e57759fa97f38 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.lang.*;
import java.util.*;
public class ComdeFormces {
public static int cc2;
public static pair pr;
public static long sum;
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
// Reader.init(System.in);
FastReader sc=new FastReader();
BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
// OutputStream out = new BufferedOutputStream ( System.out );
int t=sc.nextInt();
int tc=1;
while(t--!=0) {
int n=sc.nextInt();
int l=sc.nextInt();
int r=sc.nextInt();
int vl=l/(r+1);
int rem=l%(r+1);
int i=0;
String ans="";
while(r--!=0){
int cnt=vl;
if(rem>0) {
cnt++;
rem--;
}
while(cnt--!=0) {
ans+="R";
i++;
}
ans+="B";
}
for( i=0;i<vl;i++)ans+="R";
log.write(ans+"\n");
log.flush();
}
}
static long eval(ArrayList<ArrayList<Integer>> ar,int src,long f[], boolean vis[]) {
long mn=Integer.MAX_VALUE;
vis[src]=true;
for(int p:ar.get(src)) {
if(!vis[p]) {
long s=eval(ar,p,f,vis);
mn=Math.min(mn,s);
sum+=s;
}
}
if(src==0)return 0;
if(mn==Integer.MAX_VALUE)return f[src];
sum-=mn;
return Math.max(f[src], mn);
}
public static void radixSort(int a[]) {
int n=a.length;
int res[]=new int[n];
int p=1;
for(int i=0;i<=8;i++) {
int cnt[]=new int[10];
for(int j=0;j<n;j++) {
a[j]=res[j];
cnt[(a[j]/p)%10]++;
}
for(int j=1;j<=9;j++) {
cnt[j]+=cnt[j-1];
}
for(int j=n-1;j>=0;j--) {
res[cnt[(a[j]/p)%10]-1]=a[j];
cnt[(a[j]/p)%10]--;
}
p*=10;
}
}
static int bits(long n) {
int ans=0;
while(n!=0) {
if((n&1)==1)ans++;
n>>=1;
}
return ans;
}
static long flor(ArrayList<Long> ar,long el) {
int s=0;
int e=ar.size()-1;
while(s<=e) {
int m=s+(e-s)/2;
if(ar.get(m)==el)return ar.get(m);
else if(ar.get(m)<el)s=m+1;
else e=m-1;
}
return e>=0?e:-1;
}
public static int kadane(int a[]) {
int sum=0,mx=Integer.MIN_VALUE;
for(int i=0;i<a.length;i++) {
sum+=a[i];
mx=Math.max(mx, sum);
if(sum<0) sum=0;
}
return mx;
}
public static int m=1000000007;
public static int mul(int a, int b) {
return ((a%m)*(b%m))%m;
}
public static long mul(long a, long b) {
return ((a%m)*(b%m))%m;
}
public static int add(int a, int b) {
return ((a%m)+(b%m))%m;
}
public static long add(long a, long b) {
return ((a%m)+(b%m))%m;
}
//debug
public static <E> void p(E[][] a,String s) {
System.out.println(s);
for(int i=0;i<a.length;i++) {
for(int j=0;j<a[0].length;j++) {
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
public static void p(int[] a,String s) {
System.out.print(s+"=");
for(int i=0;i<a.length;i++)System.out.print(a[i]+" ");
System.out.println();
}
public static void p(long[] a,String s) {
System.out.print(s+"=");
for(int i=0;i<a.length;i++)System.out.print(a[i]+" ");
System.out.println();
}
public static <E> void p(E a,String s){
System.out.println(s+"="+a);
}
public static <E> void p(ArrayList<E> a,String s){
System.out.println(s+"="+a);
}
public static <E> void p(LinkedList<E> a,String s){
System.out.println(s+"="+a);
}
public static <E> void p(HashSet<E> a,String s){
System.out.println(s+"="+a);
}
public static <E> void p(Stack<E> a,String s){
System.out.println(s+"="+a);
}
public static <E> void p(Queue<E> a,String s){
System.out.println(s+"="+a);
}
//utils
static ArrayList<Integer> divisors(int n){
ArrayList<Integer> ar=new ArrayList<>();
for (int i=2; i<=Math.sqrt(n); i++){
if (n%i == 0){
if (n/i == i) {
ar.add(i);
}
else {
ar.add(i);
ar.add(n/i);
}
}
}
return ar;
}
static int primeDivisor(int n){
ArrayList<Integer> ar=new ArrayList<>();
int cnt=0;
boolean pr=false;
while(n%2==0) {
pr=true;
ar.add(2);
n/=2;
}
for(int i=3;i*i<=n;i+=2) {
pr=false;
while(n%i==0) {
n/=i;
ar.add(i);
pr=true;
}
}
if(n>2) ar.add(n);
return ar.size();
}
static long gcd(long a,long b) {
if(b==0)return a;
else return gcd(b,a%b);
}
static int gcd(int a,int b) {
if(b==0)return a;
else return gcd(b,a%b);
}
static long factmod(long n,long mod,long img) {
if(n==0)return 1;
long ans=1;
long temp=1;
while(n--!=0) {
if(temp!=img) {
ans=((ans%mod)*((temp)%mod))%mod;
}
temp++;
}
return ans%mod;
}
static int ncr(int n, int r){
if(r>n-r)r=n-r;
int ans=1;
for(int i=0;i<r;i++){
ans*=(n-i);
ans/=(i+1);
}
return ans;
}
public static class trip{
int a,b;
int c;
public trip(int a,int b,int c) {
this.a=a;
this.b=b;
this.c=c;
}
public int compareTo(trip q) {
return this.b-q.b;
}
}
static void mergesort(long[] a,int start,int end) {
if(start>=end)return ;
int mid=start+(end-start)/2;
mergesort(a,start,mid);
mergesort(a,mid+1,end);
merge(a,start,mid,end);
}
static void merge(long[] a, int start,int mid,int end) {
int ptr1=start;
int ptr2=mid+1;
long b[]=new long[end-start+1];
int i=0;
while(ptr1<=mid && ptr2<=end) {
if(a[ptr1]<=a[ptr2]) {
b[i]=a[ptr1];
ptr1++;
i++;
}
else {
b[i]=a[ptr2];
ptr2++;
i++;
}
}
while(ptr1<=mid) {
b[i]=a[ptr1];
ptr1++;
i++;
}
while(ptr2<=end) {
b[i]=a[ptr2];
ptr2++;
i++;
}
for(int j=start;j<=end;j++) {
a[j]=b[j-start];
}
}
public static class FastReader {
BufferedReader b;
StringTokenizer s;
public FastReader() {
b=new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while(s==null ||!s.hasMoreElements()) {
try {
s=new StringTokenizer(b.readLine());
}
catch(IOException e) {
e.printStackTrace();
}
}
return s.nextToken();
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str="";
try {
str=b.readLine();
}
catch(IOException e) {
e.printStackTrace();
}
return str;
}
boolean hasNext() {
if (s != null && s.hasMoreTokens()) {
return true;
}
String tmp;
try {
b.mark(1000);
tmp = b.readLine();
if (tmp == null) {
return false;
}
b.reset();
} catch (IOException e) {
return false;
}
return true;
}
}
public static class pair{
int a;
int b;
public pair(int a,int b) {
this.a=a;
this.b=b;
}
public int compareTo(pair b) {
return this.a-b.a;
}
// public int compareToo(pair b) {
// return this.b-b.b;
// }
@Override
public String toString() {
return "{"+this.a+" "+this.b+"}";
}
}
static long pow(long a, long pw) {
long temp;
if(pw==0)return 1;
temp=pow(a,pw/2);
if(pw%2==0)return temp*temp;
return a*temp*temp;
}
static int pow(int a, int pw) {
int temp;
if(pw==0)return 1;
temp=pow(a,pw/2);
if(pw%2==0)return temp*temp;
return a*temp*temp;
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | ef50e3fd3d577d4059ddd657bd9d9760 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes |
import java.util.*;
import java.lang.*;
import java.io.*;
public class New {
public static void main (String[] args) throws java.lang.Exception
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int testCases = Integer.parseInt(br.readLine());
while(testCases-->0){
String input[]=br.readLine().split(" ");
int n=Integer.parseInt(input[0]);
int r=Integer.parseInt(input[1]);
int b=Integer.parseInt(input[2]);
if(r>b) {
int t=b+1;
int d=r/t;
int g=r%t;
while(r>0||b>0) {
for(int i=0;i<d&&r>0;i++) {
out.print("R");
r--;
}
if(g-->0) {
out.print("R");
r--;
}
if(b>0) out.print("B");
b--;
}
}else {
int t=r+1;
int d=b/t;
int g=b%t;
while(b>0||r>0) {
for(int i=0;i<d&&b>0;i++) {
out.print("B");
b--;
}
if(g-->0) {
out.print("B");
b--;
}
if(r>0) out.print("R");
r--;
}
}
out.println();
}
out.close();
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 729ab1fe73125dc82cdfd79d3753aa32 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
public class cd782Div2 {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int tt = in.nextInt();
for(int w= 0; w<tt; w++) {
int n = in.nextInt();
int r = in.nextInt();
int b = in.nextInt();
int q = r%(b+1);
int p = r/(b+1);
for(int i=0; i<q; i++) {
int br=0;
while(br!=p+1) {
System.out.print("R");
br++;
}
System.out.print("B");
}
for(int i=q; i<b; i++) {
int br=0;
while(br!=p) {
System.out.print("R");
br++;
}
System.out.print("B");
}
for(int i=0; i<p; i++) {
System.out.print("R");
}
System.out.println();
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 9be7b6df2578ec4a714b926c3bc64b47 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.awt.image.AreaAveragingScaleFilter;
import java.io.*;
import java.math.BigInteger;
import java.text.DecimalFormat;
import java.util.*;
public class Pratice {
static final long mod = 1000000007;
static StringBuilder sb = new StringBuilder();
static int xn = (int) (2e5 + 10);
static long ans;
static boolean prime[] = new boolean[1000001];
// calculate sqrt and cuberoot
// static Set<Long> set=new TreeSet<>();
// static
// {
// long n=1000000001;
//
//
// for(int i=1;i*i<=n;i++)
// {
// long x=i*i;
// set.add(x);
// }
// for(int i=1;i*i*i<=n;i++)
// {
// long x=i*i*i;
// set.add(x);
// }
// }
static void sieveOfEratosthenes() {
for (int i = 0; i <= 1000000; i++)
prime[i] = true;
prime[0] = false;
prime[1] = false;
for (int p = 2; p * p <= 1000000; p++) {
if (prime[p] == true) {
for (int i = p * p; i <= 1000000; i += p)
prime[i] = false;
}
}
}
public static void main(String[] args) throws IOException {
Reader reader = new Reader();
int t = reader.nextInt();
while (t-- > 0) {
int n = reader.nextInt();
int r = reader.nextInt();
int b = reader.nextInt();
int p = r / (b + 1);
int rem = r % (b + 1);
for (int i = 0; i < rem; i++) {
for (int j = 0; j < p + 1; j++) {
System.out.print("R" + "");
}
System.out.print("B" + "");
}
for (int i = rem; i < b; i++) {
for (int j = 0; j < p; j++) {
System.out.print("R" + "");
}
System.out.print("B" + "");
}
for(int i=0;i<p;i++)
{
System.out.print("R"+"");
}
System.out.println();
}
}
// }
// static void SieveOfEratosthenes(int n, boolean prime[],
// boolean primesquare[], int a[])
// {
// // Create a boolean array "prime[0..n]" and
// // initialize all entries it as true. A value
// // in prime[i] will finally be false if i is
// // Not a prime, else true.
// for (int i = 2; i <= n; i++)
// prime[i] = true;
//
// /* Create a boolean array "primesquare[0..n*n+1]"
// and initialize all entries it as false.
// A value in squareprime[i] will finally
// be true if i is square of prime,
// else false.*/
// for (int i = 0; i < ((n * n) + 1); i++)
// primesquare[i] = false;
//
// // 1 is not a prime number
// prime[1] = false;
//
// for (int p = 2; p * p <= n; p++) {
// // If prime[p] is not changed,
// // then it is a prime
// if (prime[p] == true) {
// // Update all multiples of p
// for (int i = p * 2; i <= n; i += p)
// prime[i] = false;
// }
// }
//
// int j = 0;
// for (int p = 2; p <= n; p++) {
// if (prime[p]) {
//
// a[j] = p;
//
//
// primesquare[p * p] = true;
// j++;
// }
// }
// }
//
//
// static int countDivisors(int n)
// {
//
// if (n == 1)
// return 1;
//
// boolean prime[] = new boolean[n + 1];
// boolean primesquare[] = new boolean[(n * n) + 1];
//
// int a[] = new int[n];
//
//
// SieveOfEratosthenes(n, prime, primesquare, a);
//
//
// int ans = 1;
//
// // Loop for counting factors of n
// for (int i = 0;; i++) {
// // a[i] is not less than cube root n
// if (a[i] * a[i] * a[i] > n)
// break;
//
// int cnt = 1;
//
// // if a[i] is a factor of n
// while (n % a[i] == 0) {
// n = n / a[i];
//
// // incrementing power
// cnt = cnt + 1;
// }
//
//
// ans = ans * cnt;
// }
//
//
// if (prime[n])
// ans = ans * 2;
//
// // Second case
// else if (primesquare[n])
// ans = ans * 3;
//
// // Third case
// else if (n != 1)
// ans = ans * 4;
//
// return ans; // Total divisors
// }
public static long[] inarr(long n) throws IOException {
Reader reader = new Reader();
long arr[]=new long[(int) n];
for (long i = 0; i < n; i++) {
arr[(int) i]=reader.nextLong();
}
return arr;
}
public static boolean checkPerfectSquare(int number)
{
int x=number % 10;
if (x==2 || x==3 || x==7 || x==8)
{
return false;
}
for (int i=0; i<=number/2 + 1; i++)
{
if (i*i==number)
{
return true;
}
}
return false;
}
// check number is prime or not
public static boolean isPrime(int n) {
return BigInteger.valueOf(n).isProbablePrime(1);
}
// return the gcd of two numbers
public static long gcd(long a, long b)
{
BigInteger b1 = BigInteger.valueOf(a);
BigInteger b2 = BigInteger.valueOf(b);
BigInteger gcd = b1.gcd(b2);
return gcd.longValue();
}
// return lcm of number
static long lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
// number of digits in the given number
public static long numberOfDigits(long n)
{
long ans= (long) (Math.floor((Math.log10(n)))+1);
return ans;
}
// return most significant bit in the number
public static long mostSignificantNumber(long n)
{
double k=Math.log10(n);
k=k-Math.floor(k);
int ans=(int)Math.pow(10,k);
return ans;
}
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException {
din = new DataInputStream(new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException {
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n')
break;
buf[cnt++] = (byte) c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
}
while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException {
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException {
if (din == null)
return;
din.close();
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | c9eea7cd50b0dba6dabc5345b59b85bc | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.stream.IntStream;
import java.util.*;
public class sol {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt(),r=sc.nextInt(),b=sc.nextInt(),cnt=0;
cnt=r%(b+1);
for(int i=0;i<(b+1);i++){
for(int j=0;j<r/(b+1);j++){
System.out.print("R");
}
if(cnt>0){
System.out.print("R");
cnt--;
}
if(i<b){
System.out.print("B");
}
}
System.out.println();
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 2d2bca8466659c73b6d3404abc036dc7 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
public class Main{
public static void main(String []args){
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while(t-->0){
int n = scn.nextInt();
int r = scn.nextInt();
int b = scn.nextInt();
int q = r/(b+1);
int rem = r%(b+1);
for(int i=0;i<b+1;i++){
for(int j=0;j<q;j++){
System.out.print("R");
}
if(rem>0){
System.out.print("R");
rem--;
}
if(i==b) break;
System.out.print("B");
}
System.out.println();
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 30b142b3ce063219b7c0ad654115ee22 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | /**
* Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
* <p>
* To modify the template, go to Preferences -> Editor -> File and Code Templates -> Other
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import static java.lang.Math.*;
public class Main {
static PrintWriter out;
public static void main(String[] args) {
FastReader in = new FastReader();
out = new PrintWriter(System.out);
long t = in.nextLong();
long test = 1;
while (test <= t) {
out.println(solve(in));
// solve(in);
test++;
}
out.close();
}
/*--------------------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------------------------*/
// private static void solve(FastReader in) {
//
//
// }
// private static long solve(FastReader in) {
//
//
// }
private static String solve(FastReader in) {
int n = in.nextInt();
int r = in.nextInt();
int b = in.nextInt();
StringBuilder sb = new StringBuilder();
// F0R(i, Y) {
// F0R(j, K) {
// cout << 'R';
// }
// if (i < X % (Y+1)) {
// cout << 'R';
// }
// cout << 'B';
// }
// F0R(i, K) cout << 'R';
// cout << nl;
int k = r / (b + 1);
int rem = r % (b + 1);
for (int i = 0; i < b; i++) {
for (int j = 0; j < k; j++) sb.append("R");
if (rem-- > 0)
sb.append("R");
sb.append("B");
}
for (int i = 0; i < k; i++) sb.append("R");
return sb.toString();
}
/*--------------------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------------------------*/
private static int gcd(int a, int b) {
return b == 0 ? a : (gcd(b, a % b));
}
static boolean[] sieveOfEratosthenes(int n) {
boolean[] prime = new boolean[n + 1];
Arrays.fill(prime, true);
prime[0] = prime[1] = false;
for (int p = 2; p * p <= n; p++) {
if (prime[p]) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
return prime;
}
static void sort(int[] a) {
List<Integer> l = new ArrayList<>();
for (int i : a) l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++) a[i] = l.get(i);
}
static long modPow(long a, long b, long m) {
long res = 1;
a %= m;
while (b > 0) {
if ((b & 1) != 0) {
res = res * a;
res %= m;
}
b >>= 1;
a *= a;
a %= m;
}
return res;
}
private static class Pair implements Comparable<Pair> {
int ff, ss;
Pair(int x, int y) {
this.ff = x;
this.ss = y;
}
public int compareTo(Pair o) {
return this.ff == o.ff ? this.ss - o.ss : this.ff - o.ff;
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | c177787e6e643972e08eec509add8b67 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | /**
* Accomplished using the EduTools plugin by JetBrains https://plugins.jetbrains.com/plugin/10081-edutools
* <p>
* To modify the template, go to Preferences -> Editor -> File and Code Templates -> Other
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
import static java.lang.Math.*;
public class Main {
static PrintWriter out;
public static void main(String[] args) {
FastReader in = new FastReader();
out = new PrintWriter(System.out);
long t = in.nextLong();
long test = 1;
while (test <= t) {
out.println(solve(in));
// solve(in);
test++;
}
out.close();
}
/*--------------------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------------------------*/
// private static void solve(FastReader in) {
//
//
// }
// private static long solve(FastReader in) {
//
//
// }
private static String solve(FastReader in) {
int n = in.nextInt();
int r = in.nextInt();
int b = in.nextInt();
StringBuilder sb = new StringBuilder();
// F0R(i, Y) {
// F0R(j, K) {
// cout << 'R';
// }
// if (i < X % (Y+1)) {
// cout << 'R';
// }
// cout << 'B';
// }
// F0R(i, K) cout << 'R';
// cout << nl;
int k = r / (b + 1);
for (int i = 0; i < b; i++) {
for (int j = 0; j < k; j++) sb.append("R");
if (i < r % (b + 1))
sb.append("R");
sb.append("B");
}
for (int i = 0; i < k; i++) sb.append("R");
return sb.toString();
}
/*--------------------------------------------------------------------------------------------------------------------------------*/
/*--------------------------------------------------------------------------------------------------------------------------------*/
private static int gcd(int a, int b) {
return b == 0 ? a : (gcd(b, a % b));
}
static boolean[] sieveOfEratosthenes(int n) {
boolean[] prime = new boolean[n + 1];
Arrays.fill(prime, true);
prime[0] = prime[1] = false;
for (int p = 2; p * p <= n; p++) {
if (prime[p]) {
for (int i = p * p; i <= n; i += p)
prime[i] = false;
}
}
return prime;
}
static void sort(int[] a) {
List<Integer> l = new ArrayList<>();
for (int i : a) l.add(i);
Collections.sort(l);
for (int i = 0; i < a.length; i++) a[i] = l.get(i);
}
static long modPow(long a, long b, long m) {
long res = 1;
a %= m;
while (b > 0) {
if ((b & 1) != 0) {
res = res * a;
res %= m;
}
b >>= 1;
a *= a;
a %= m;
}
return res;
}
private static class Pair implements Comparable<Pair> {
int ff, ss;
Pair(int x, int y) {
this.ff = x;
this.ss = y;
}
public int compareTo(Pair o) {
return this.ff == o.ff ? this.ss - o.ss : this.ff - o.ff;
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++) a[i] = nextInt();
return a;
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 0d9f1be10b6d05d938c3eb102dfcf158 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.math.BigInteger;
import java.util.Scanner;
public class codefrces {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
for(int i = 0; i < t; i++) {
int n = scanner.nextInt(), r = scanner.nextInt(), b = scanner.nextInt();
int d = r / (b+1), tt = r % (b + 1);
for(int j = 1; j <= b + 1; j++) {
for(int k = 1; k <= d + (j <= tt ? 1 : 0); k++) {
System.out.print("R");
}
if(j <= b) {
System.out.print("B");
}
}
System.out.println();
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | fc0b567c9b289e910dffab01ec6f050f | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes |
import java.util.Arrays;
import java.util.Scanner;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author abrianna-kevin
*/
public class p1 {
static int n;
static int r;
static int b;
/**
* @param args the command line arguments
*/
public static void main(String args[]){
// TODO code application logic here
Scanner s = new Scanner(System.in);
StringBuilder ans = new StringBuilder();
int t = s.nextInt();
for (int curtest = 0; curtest < t; curtest++){
n = s.nextInt();
r = s.nextInt();
b = s.nextInt();
while (r+b > 0){
// printint(r+b, "r+b");
// print(ans);
ans.append(buildstr());
}
if (curtest!= t-1){
ans.append("\n");
}
}
print(ans);
}
public static boolean getans(){
return false;
}
public static String buildstr(){
StringBuilder ans = new StringBuilder();
if (b == 0){
for (int i = 0; i < r; i++){
ans.append("R");
r--;
}
return ans.toString();
}
if (r == 0){
for (int i = 0; i < b; i++){
ans.append("B");
b--;
}
return ans.toString();
}
// printint(r, "r");
// printint(b, "b");
int x = (int) Math.ceil((double)r/(b+1));
// printint(x, "x");
// printint(k, "k");
while (x == Math.ceil((double)r/(b+1))){
for (int j = 0; j < x; j++){
ans.append("R");
r--;
}
if (b != 0){
ans.append("B");
b--;
}
}
return ans.toString();
}
public static void print(Object i){
System.out.println(i);
}
public static void printf(String i){
System.out.printf(i);
}
public static void printint(int i, String name){
System.out.println(name + " = " + String.valueOf(i));
}
public static void printintarr(int[] arr){
System.out.println(Arrays.toString(arr));
}
}
// public static class Point{
// int x;
// int y;
//
// public Point(int scanx, int scany){
// x = scanx;
// y = scany;
// }
// }
// public static void printarr(int[][] arr){
// for (int[] i: arr){
// System.out.println(Arrays.toString(i));
// }
// }
// public static class SortMeasurement implements Comparator<Measurement> {
// @Override
// public int compare(Measurement measure1, Measurement measure2){
// return measure1.day - measure2.day;
// }
// }
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | ada77af496084f51e9ea635b58d9870e | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.*;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void main(String[] args)
{
FastReader s = new FastReader();
int t = s.nextInt();
while (t-- > 0){
int n = s.nextInt();
int r = s.nextInt();
int b = s.nextInt();
int p = r/(b+1), q = r%(b+1);
String str = "";
for (int i = 0; i < q; i++){
for (int j = 0; j < p+1; j++){
str += "R";
}
str += "B";
}
for (int i = q; i < b; i++){
for (int j = 0; j < p; j++){
str += "R";
}
str += "B";
}
for (int j = 0; j < p; j++){
str += "R";
}
System.out.println(str);
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 9f0ee9314e5f1cb1cb5d3710842474e9 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes |
import java.util.*;
public class Problem1659A {
public static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int tc = scanner.nextInt();
while (tc-->0) {
int n = scanner.nextInt();
int r = scanner.nextInt();
int b = scanner.nextInt();
while (b > 0) {
int len = (int) Math.ceil((double) r / (b + 1));
for (int i = 0; i < len; i++) {
System.out.print("R");
}
System.out.print("B");
b--;
r -=len;
}
while (r > 0) {
System.out.print("R");
r--;
}
System.out.println();
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | da8ec7f31df37812c43bb8020d246830 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes |
import java.util.*;
public class Problem1659A {
public static Scanner scanner = new Scanner(System.in);
public static void main(String[] args) {
int tc = scanner.nextInt();
while (tc-->0){
int n = scanner.nextInt();
int r = scanner.nextInt();
int b = scanner.nextInt();
while (b>0){
int len= (int) Math.ceil((double) r/(b+1));
for (int i = 0; i <len ; i++) {
System.out.print("R");
}
System.out.print("B");
b--;
r=r-len;
}
while (r>0){
System.out.print("R");
r--;
}
System.out.println();
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 7fc36fb1b2433e89a27cddf74061e737 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | /* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scn = new Scanner(System.in);
int t = scn.nextInt();
while(t>0){
int n = scn.nextInt();
int r = scn.nextInt();
int b = scn.nextInt();
char st = 'R';
char m ='B';
int k = b, g = r;
if(b>r){
st = 'B';
m = 'R';
k = r;
g = b;
}
int c = g/(k+1);
if(g%(k+1)!=0){
c++;
}
StringBuffer sb = new StringBuffer("");
int idx = 1;
while(k>0 || g>0){
int cc = c;
boolean x = false;
while(cc>0 && g>0){
sb.append(st);
g--;
x = true;
cc--;
}
if(k>0){
if(x==false && c>1 && idx<sb.length()){
sb.insert(idx,m);
idx=idx+c+2;
}else{
sb.append(m);
}
k--;
}
}
System.out.println(sb.toString());
t--;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | e6d83a1bef1a98f5fe71142291d668dd | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.OutputStream;
import java.io.BufferedOutputStream;
import java.util.*;
public class CodeForces_782_A {
public static void main(String[] args)throws Exception{
FastScanner in = new FastScanner();OutputStream out = new BufferedOutputStream ( System.out );
int t=in.nextInt();
while(t-->0){
int n=in.nextInt();int a=in.nextInt();int b=in.nextInt();char[] c=new char[n];
int d=a/(b+1);int e=a%(b+1);int i=0;
int grp1=(b+1-e);
while(grp1-->0){
for(int k=0;k<d && i<n;k++){
c[i]='R';i++;
}
if(i<n){
c[i]='B';i++;
}
}
while(e-->0){
for(int k=0;k<(d+1) && i<n;k++){
c[i]='R';i++;
}
if(i!=n){
c[i]='B';i++;
}
}
for(int j=0;j<n;j++){
out.write(c[j]);
}
out.write("\n".getBytes());
}
out.flush();
}
public static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(String s) {
try {
br = new BufferedReader(new FileReader(s));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
public FastScanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String nextToken() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(nextToken());
}
long nextLong() {
return Long.parseLong(nextToken());
}
double nextDouble() {
return Double.parseDouble(nextToken());
}
String nextLine()
{
String str = "";
try
{
str = br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 2b2fcebfac704109abf0090b717d454b | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | /*LoudSilence*/
import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Solution {
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
static FastScanner s = new FastScanner();
static FastWriter out = new FastWriter();
final static int mod = (int)1e9 + 7;
final static int INT_MAX = Integer.MAX_VALUE;
final static int INT_MIN = Integer.MIN_VALUE;
final static long LONG_MAX = Long.MAX_VALUE;
final static long LONG_MIN = Long.MIN_VALUE;
final static double DOUBLE_MAX = Double.MAX_VALUE;
final static double DOUBLE_MIN = Double.MIN_VALUE;
final static float FLOAT_MAX = Float.MAX_VALUE;
final static float FLOAT_MIN = Float.MIN_VALUE;
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
static class FastScanner{BufferedReader br;StringTokenizer st;
public FastScanner() {if(System.getProperty("ONLINE_JUDGE") == null){try {br = new BufferedReader(new FileReader("E:\\Competitive Coding\\input.txt"));}
catch (FileNotFoundException e) {br = new BufferedReader(new InputStreamReader(System.in));}}else{br = new BufferedReader(new InputStreamReader(System.in));}}
String next(){while (st == null || !st.hasMoreElements()){try{st = new StringTokenizer(br.readLine());}catch (IOException e){e.printStackTrace();}}return st.nextToken();}
int nextInt(){return Integer.parseInt(next());}
long nextLong(){return Long.parseLong(next());}
double nextDouble(){return Double.parseDouble(next());}
List<Integer> readIntList(int n){List<Integer> arr = new ArrayList<>(); for(int i = 0; i < n; i++) arr.add(s.nextInt()); return arr;}
List<Long> readLongList(int n){List<Long> arr = new ArrayList<>(); for(int i = 0; i < n; i++) arr.add(s.nextLong()); return arr;}
int[] readIntArr(int n){int[] arr = new int[n]; for (int i = 0; i < n; i++) arr[i] = s.nextInt(); return arr;}
long[] readLongArr(int n){long[] arr = new long[n]; for (int i = 0; i < n; i++) arr[i] = s.nextLong(); return arr;}
String nextLine(){String str = "";try{str = br.readLine();}catch (IOException e){e.printStackTrace();}return str;}}
static class FastWriter{private BufferedWriter bw;public FastWriter(){if(System.getProperty("ONLINE_JUDGE") == null){try {this.bw = new BufferedWriter(new FileWriter("E:\\Competitive Coding\\output.txt"));}
catch (IOException e) {this.bw = new BufferedWriter(new OutputStreamWriter(System.out));}}else{this.bw = new BufferedWriter(new OutputStreamWriter(System.out));}}
public void print(Object object) throws IOException{bw.append(""+ object);}
public void println(Object object) throws IOException{print(object);bw.append("\n");}
public void debug(int object[]) throws IOException{bw.append("["); for(int i = 0; i < object.length; i++){if(i != object.length-1){print(object[i]+", ");}else{print(object[i]);}}bw.append("]\n");}
public void debug(long object[]) throws IOException{bw.append("["); for(int i = 0; i < object.length; i++){if(i != object.length-1){print(object[i]+", ");}else{print(object[i]);}}bw.append("]\n");}
public void close() throws IOException{bw.close();}}
public static void println(Object str) throws IOException{out.println(""+str);}
public static void println(Object str, int nextLine) throws IOException{out.print(""+str);}
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
public static ArrayList<Integer> seive(int n){ArrayList<Integer> list = new ArrayList<>();int arr[] = new int[n+1];for(long i = 2; i <= n; i++) {if(arr[(int)i] == 1) {continue;}else {list.add((int)i);for(long j = i*i; j <= n; j = j + i) {arr[(int)j] = 1;}}}return list;}
public static long gcd(long a, long b){if(a > b) {a = (a+b)-(b=a);}if(a == 0L){return b;}return gcd(b%a, a);}
public static void swap(int[] arr, int i, int j) {arr[i] = arr[i] ^ arr[j]; arr[j] = arr[j] ^ arr[i]; arr[i] = arr[i] ^ arr[j];}
public static boolean isPrime(long n){if(n < 2){return false;}if(n == 2 || n == 3){return true;}if(n%2 == 0 || n%3 == 0){return false;}long sqrtN = (long)Math.sqrt(n)+1;for(long i = 6L; i <= sqrtN; i += 6) {if(n%(i-1) == 0 || n%(i+1) == 0) return false;}return true;}
public static long mod_add(long a, long b){ return (a%mod + b%mod)%mod;}
public static long mod_sub(long a, long b){ return (a%mod - b%mod + mod)%mod;}
public static long mod_mul(long a, long b){ return (a%mod * b%mod)%mod;}
public static long modInv(long a, long b){ return expo(a, b-2)%b;}
public static long mod_div(long a, long b){return mod_mul(a, modInv(b, mod));}
public static long expo (long a, long n){if(n == 0){return 1;}long recAns = expo(mod_mul(a,a), n/2);if(n % 2 == 0){return recAns;}else{return mod_mul(a, recAns);}}
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
// Pair class
public static class Pair<X extends Comparable<X>,Y extends Comparable<Y>> implements Comparable<Pair<X, Y>>{
X first;
Y second;
public Pair(X first, Y second){
this.first = first;
this.second = second;
}
public String toString(){
return "( " + first+" , "+second+" )";
}
@Override
public int compareTo(Pair<X, Y> o) {
int t = first.compareTo(o.first);
if(t == 0) return second.compareTo(o.second);
return t;
}
}
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
// Code begins
public static void solve() throws IOException {
int n = s.nextInt();
int r = s.nextInt();
int b = s.nextInt();
StringBuilder ans[] = new StringBuilder[2*b+1];
for(int i = 0; i < ans.length; i++) ans[i] = new StringBuilder();
for(int i = 1; i < ans.length; i+=2){
ans[i].append("B");
}
int idx = 0;
for(int i = 0; i < r; i++){
ans[idx].append("R");
if(idx == ans.length-1){
idx = 0;
continue;
}
idx = (idx+2)% ans.length;
}
for(int i = 0; i < ans.length; i++){
println(ans[i].toString(),1);
}
println("");
}
/*----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
public static void main(String[] args) throws IOException {
int test = s.nextInt();
for(int t = 1; t <= test; t++) {
solve();
}
out.close();
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 364a4b34481f19987b9b5f0f89d60fdc | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
public class Main
{
static long mod = (int)1e9+7;
static PrintWriter out=new PrintWriter(new BufferedOutputStream(System.out));
public static void main (String[] args) throws java.lang.Exception
{
FastReader sc =new FastReader();
int t=sc.nextInt();
// int t=1;
O : while(t-->0)
{
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
char[] ans=new char[n];
int m=r/(b+1);
int h=r%(b+1);
int idx=0;
for(int i=0;i<h;i++){
for(int j=0;j<m+1;j++)
ans[idx++]='R';
if (idx<n-1)
ans[idx++]='B';
}
for(int i=0;i<b+1-h;i++){
for (int j=0;j<m;j++)
ans[idx++]='R';
if(idx<n-1)
ans[idx++]='B';
}
out.println(ans);
}
out.flush();
}
static void printN()
{
System.out.println("NO");
}
static void printY()
{
System.out.println("YES");
}
static int findfrequencies(int a[],int n)
{
int count=0;
for(int i=0;i<a.length;i++)
{
if(a[i]==n)
{
count++;
}
}
return count;
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
float nextFloat()
{
return Float.parseFloat(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long[] readArrayLong(int n) {
long[] a=new long[n];
for (int i=0; i<n; i++) a[i]=nextLong();
return a;
}
}
public static int[] radixSort2(int[] a)
{
int n = a.length;
int[] c0 = new int[0x101];
int[] c1 = new int[0x101];
int[] c2 = new int[0x101];
int[] c3 = new int[0x101];
for(int v : a) {
c0[(v&0xff)+1]++;
c1[(v>>>8&0xff)+1]++;
c2[(v>>>16&0xff)+1]++;
c3[(v>>>24^0x80)+1]++;
}
for(int i = 0;i < 0xff;i++) {
c0[i+1] += c0[i];
c1[i+1] += c1[i];
c2[i+1] += c2[i];
c3[i+1] += c3[i];
}
int[] t = new int[n];
for(int v : a)t[c0[v&0xff]++] = v;
for(int v : t)a[c1[v>>>8&0xff]++] = v;
for(int v : a)t[c2[v>>>16&0xff]++] = v;
for(int v : t)a[c3[v>>>24^0x80]++] = v;
return a;
}
static int[] EvenOddArragement(int a[])
{
ArrayList<Integer> list=new ArrayList<>();
for(int i=0;i<a.length;i++)
{
if(a[i]%2==0)
{
list.add(a[i]);
}
}
for(int i=0;i<a.length;i++)
{
if(a[i]%2!=0)
{
list.add(a[i]);
}
}
for(int i=0;i<a.length;i++)
{
a[i]=list.get(i);
}
return a;
}
static int gcd(int a, int b) {
while (b != 0) {
int t = a;
a = b;
b = t % b;
}
return a;
}
static int lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
public static HashMap<Integer, Integer> sortByValue(HashMap<Integer, Integer> hm)
{
// Create a list from elements of HashMap
List<Map.Entry<Integer, Integer> > list =
new LinkedList<Map.Entry<Integer, Integer> >(hm.entrySet());
// Sort the list
Collections.sort(list, new Comparator<Map.Entry<Integer, Integer> >() {
public int compare(Map.Entry<Integer, Integer> o1,
Map.Entry<Integer, Integer> o2)
{
return (o1.getValue()).compareTo(o2.getValue());
}
});
// put data from sorted list to hashmap
HashMap<Integer, Integer> temp = new LinkedHashMap<Integer, Integer>();
for (Map.Entry<Integer, Integer> aa : list) {
temp.put(aa.getKey(), aa.getValue());
}
return temp;
}
static int DigitSum(int n)
{
int r=0,sum=0;
while(n>=0)
{
r=n%10;
sum=sum+r;
n=n/10;
}
return sum;
}
static boolean checkPerfectSquare(int number)
{
double sqrt=Math.sqrt(number);
return ((sqrt - Math.floor(sqrt)) == 0);
}
static boolean isPowerOfTwo(int n)
{
if(n==0)
return false;
return (int)(Math.ceil((Math.log(n) / Math.log(2)))) == (int)(Math.floor(((Math.log(n) / Math.log(2)))));
}
static boolean isPrime2(int n)
{
if (n <= 1)
{
return false;
}
if (n == 2)
{
return true;
}
if (n % 2 == 0)
{
return false;
}
for (int i = 3; i <= Math.sqrt(n) + 1; i = i + 2)
{
if (n % i == 0)
{
return false;
}
}
return true;
}
static String minLexRotation(String str)
{
int n = str.length();
String arr[] = new String[n];
String concat = str + str;
for(int i=0;i<n;i++)
{
arr[i] = concat.substring(i, i + n);
}
Arrays.sort(arr);
return arr[0];
}
static String maxLexRotation(String str)
{
int n = str.length();
String arr[] = new String[n];
String concat = str + str;
for (int i = 0; i < n; i++)
{
arr[i] = concat.substring(i, i + n);
}
Arrays.sort(arr);
return arr[arr.length-1];
}
static class P implements Comparable<P> {
int i, j;
public P(int i, int j) {
this.i=i;
this.j=j;
}
public int compareTo(P o) {
return Integer.compare(i, o.i);
}
}
static class pair{
int i,j;
pair(int x,int y){
i=x;
j=y;
}
}
static int binary_search(int a[],int value)
{
int start=0;
int end=a.length-1;
int mid=start+(end-start)/2;
while(start<=end)
{
if(a[mid]==value)
{
return mid;
}
if(a[mid]>value)
{
end=mid-1;
}
else
{
start=mid+1;
}
mid=start+(end-start)/2;
}
return -1;
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | d65c3299b629fa130e5521c094674588 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class forces {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
int x = r / (b + 1);
int y = r % (b + 1);
StringBuilder s = new StringBuilder();
int c = b + 1;
while (c-- > 0) {
for (int i = 0; i < x; i++) {
s.append('R');
}
if (y > 0) {
s.append('R');
y--;
}
if (b > 0) {
b--;
s.append('B');
}
}
System.out.println(s.toString());
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | ad742df3351de0a8ba386ce4b139dd4c | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class forces {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
int x = r / (b + 1);
int y = r % (b + 1);
StringBuffer s = new StringBuffer();
int c = b + 1;
while (c-- > 0) {
for (int i = 0; i < x; i++) {
s.append('R');
}
if (y > 0) {
s.append('R');
y--;
}
if (b > 0) {
b--;
s.append('B');
}
}
System.out.println(s.toString());
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 9e379b855d1b012a03e5adbf68991d92 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class forces {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
int x = r / (b + 1);
int y = r % (b + 1);
String s = "";
int c = b + 1;
while (c-- > 0) {
for (int i = 0; i < x; i++) {
s = s + "R";
}
if (y > 0) {
s = s + 'R';
y--;
}
if (b > 0) {
b--;
s = s + 'B';
}
}
System.out.println(s);
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | e625b34410562fb71781a1be83c01092 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.*;
// Solution
public class Solution {
static InputStream is;
static PrintWriter out;
static String INPUT = "";
public static int gcd(int a, int b) {
if (b==0) return a;
return gcd(b,a%b);
}
public static long gcd(long a, long b) {
if (b==0) return a;
return gcd(b,a%b);
}
static boolean[] calPrime(int n) {
boolean[] isPrime = new boolean[n+1];
for(int i=2;i<=n;i++) {
isPrime[i] = true;
}
for(int factor=2;factor*factor <= n;factor++) {
if(isPrime[factor]) {
for(int j=factor;factor*j<=n;j++) {
isPrime[factor*j] = false;
}
}
}
return isPrime;
}
static void solve()
{
for(int T = ni(), cas = 1;T > 0;T--,cas++){
//out.print("Case #" + cas + ": ");
sub();
}
}
static void sub()
{
int n = ni();
int r = ni();
int b = ni();
int ma = r/(b+1);
int cb = r%(b+1);
//every segments put b
String ret="";
StringBuilder sb = new StringBuilder();
for(int i=0;i<ma;i++) {
sb.append('R');
}
sb.append('B');
for(int i=0;i<(b+1-cb);i++) {
ret += sb.toString();
}
StringBuilder sb1 = new StringBuilder();
for(int i=0;i<ma+1;i++) {
sb1.append('R');
}
sb1.append('B');
for(int i=0;i<cb;i++) {
ret+=sb1.toString();
}
out.println(ret.substring(0, ret.length()-1));
}
public static void main(String[] args) throws Exception
{
long S = System.currentTimeMillis();
is = INPUT.isEmpty() ? System.in : new ByteArrayInputStream(INPUT.getBytes());
out = new PrintWriter(System.out);
solve();
out.flush();
long G = System.currentTimeMillis();
tr(G-S+"ms");
}
private static boolean eof()
{
if(lenbuf == -1)return true;
int lptr = ptrbuf;
while(lptr < lenbuf)if(!isSpaceChar(inbuf[lptr++]))return false;
try {
is.mark(1000);
while(true){
int b = is.read();
if(b == -1){
is.reset();
return true;
}else if(!isSpaceChar(b)){
is.reset();
return false;
}
}
} catch (IOException e) {
return true;
}
}
private static byte[] inbuf = new byte[1024];
static int lenbuf = 0, ptrbuf = 0;
private static int readByte()
{
if(lenbuf == -1)throw new InputMismatchException();
if(ptrbuf >= lenbuf){
ptrbuf = 0;
try { lenbuf = is.read(inbuf); } catch (IOException e) { throw new InputMismatchException(); }
if(lenbuf <= 0)return -1;
}
return inbuf[ptrbuf++];
}
private static boolean isSpaceChar(int c) { return !(c >= 33 && c <= 126); }
// private static boolean isSpaceChar(int c) { return !(c >= 32 && c <= 126); }
private static int skip() { int b; while((b = readByte()) != -1 && isSpaceChar(b)); return b; }
private static double nd() { return Double.parseDouble(ns()); }
private static char nc() { return (char)skip(); }
private static String ns()
{
int b = skip();
StringBuilder sb = new StringBuilder();
while(!(isSpaceChar(b))){
sb.appendCodePoint(b);
b = readByte();
}
return sb.toString();
}
private static char[] ns(int n)
{
char[] buf = new char[n];
int b = skip(), p = 0;
while(p < n && !(isSpaceChar(b))){
buf[p++] = (char)b;
b = readByte();
}
return n == p ? buf : Arrays.copyOf(buf, p);
}
private static char[][] nm(int n, int m)
{
char[][] map = new char[n][];
for(int i = 0;i < n;i++)map[i] = ns(m);
return map;
}
private static int[] na(int n)
{
int[] a = new int[n];
for(int i = 0;i < n;i++)a[i] = ni();
return a;
}
private static int ni()
{
int num = 0, b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private static long nl()
{
long num = 0;
int b;
boolean minus = false;
while((b = readByte()) != -1 && !((b >= '0' && b <= '9') || b == '-'));
if(b == '-'){
minus = true;
b = readByte();
}
while(true){
if(b >= '0' && b <= '9'){
num = num * 10 + (b - '0');
}else{
return minus ? -num : num;
}
b = readByte();
}
}
private static void tr(Object... o) { if(INPUT.length() != 0)System.out.println(Arrays.deepToString(o)); }
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 4c25df5c776770a1ed1aaab6e8b74283 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class ProblemA {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int cases = Integer.parseInt(br.readLine());
for (int i = 0; i < cases; i++) {
StringTokenizer st = new StringTokenizer(br.readLine());
int size = Integer.parseInt(st.nextToken());
int red = Integer.parseInt(st.nextToken());
int blue = Integer.parseInt(st.nextToken());
System.out.println(solve(size, red, blue));
}
}
private static String solve(int size, int red, int blue) {
String res = "";
String[] list = new String[blue];
for (int i = 0; i < blue; i++) {
list[i] = "B";
}
int i = 0;
int cont = 0;
while(true){
if (i!=blue - 1){
list[i] = "R" + list[i];
i++;
} else {
list[i] = "R" + list[i] + "R";
i = 0;
cont++;
}
cont++;
if (cont >= red){
break;
}
}
for (String str:list) {
res = res + str;
}
return res.substring(0, size);
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 4f536d7790f72f6f178cb4d6d82d9f26 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | /* package codechef; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner cin=new Scanner(System.in);
int t=cin.nextInt();
while(t-->0)
{
int n=cin.nextInt();
int r=cin.nextInt();
int b=cin.nextInt();
int d=0,e=0;
if(r%(b+1)>0)
{
d=(r/(b+1))+1;
e=(r%(b+1));
}
else{
d=(r/(b+1));
e=b;
}
//int e=(r%(b+1));
int count=0;
StringBuilder s1=new StringBuilder();
for(int i=0;i<b;i++)
{
if(count<e)
{
for(int j=0;j<d;j++)
s1.append("R");
s1.append("B");
count++;
}
else
{
if(d!=1)
{
for(int j=0;j<d-1;j++)
s1.append("R");
s1.append("B");
}
else{
s1.append("R");
s1.append("B");}
}
}
if(r%(b+1)>0){
for(int j=0;j<d-1;j++)
s1.append("R");}
else{
for(int j=0;j<d;j++)
s1.append("R");
}
System.out.println(s1);
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 16ecab820023d7c22fa8075e5b99709c | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class G {
static FastScanner fs = new FastScanner();
static PrintWriter pw = new PrintWriter(System.out);
static StringBuilder sb = new StringBuilder("");
static Scanner scn = new Scanner(System.in);
public static void main(String[] args) {
int t = fs.nextInt();
for (int tt = 0; tt < t; tt++) {
int n = fs.nextInt();
int r = fs.nextInt();
int b = fs.nextInt();
int mx = Math.max(r, b);
int mn = Math.min(r, b);
double d = Math.abs((double)mx / (mn + 1));
int cnt = 0;
int d2 = (int) d;
for (int i = 0; i < b; i++) {
if (i < ((d - d2) * (b+1))-1) for (int j = 0; j <= d2; j++) {
sb.append("R");
cnt++;
}
else for (int j = 0; j < d2; j++) {
sb.append("R");
cnt++;
}
sb.append("B");
}
if (cnt < r) for (int i = cnt; i < r; i++) sb.append("R");
else for (int i = 0; i < d2; i++) sb.append("R");
sb.append("\n");
}
pw.print(sb.toString());
pw.close();
}
static void sort(int[] a) {
ArrayList<Integer> al = new ArrayList<>();
for (int i : a)
al.add(i);
Collections.sort(al);
for (int i = 0; i < a.length; i++)
a[i] = al.get(i);
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {while (!st.hasMoreTokens())try {st = new StringTokenizer(br.readLine());} catch (IOException e) {}return st.nextToken();}
int nextInt() {return Integer.parseInt(next());}
long nextLong() {return Long.parseLong(next());}
double nextDouble() {return Double.parseDouble(next());}
int[] readArray(int n) { int[] a = new int[n]; for (int i = 0; i < n; i++) {a[i] = nextInt();} return a;}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | e488137ae6beb8b6aa72f1fad31c1352 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class q1 {
public static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
// public static long mod = 1000000007;
static Boolean[][][][] dp;
static String ans;
public static boolean recursion(int r,int b,int max,int prev,int prevC,StringBuilder asf){
if(r == 0 && b == 0){
ans = asf.toString();
return true;
}
if(prevC != -1 && dp[r][b][prev][prevC] != null) return false;
if(prevC != -1) dp[r][b][prev][prevC] = true;
if(r > 0){
asf.append("R");
if(prevC == 0){
if(prev + 1 <= max && recursion(r - 1,b,max,prev + 1,0,asf)) return true;
}else{
if(recursion(r - 1,b,max,1,0,asf)) return true;
}
asf.deleteCharAt(asf.length() - 1);
}
if(b > 0){
asf.append("B");
if(prevC == 1){
if(prev + 1 <= max && recursion(r,b - 1,max,prev + 1,1,asf)) return true;
}else{
if(recursion(r,b - 1,max,1,1,asf)) return true;
}
asf.deleteCharAt(asf.length() - 1);
}
return false;
}
public static void solve() throws Exception {
String[] parts = br.readLine().split(" ");
int n = Integer.parseInt(parts[0]);
int r = Integer.parseInt(parts[1]);
int b = Integer.parseInt(parts[2]);
StringBuilder sb = new StringBuilder();
int max = 0;
for(int i = 1;i <= r;i++){
if((b + 1) * i < r) continue;
max = i;
break;
}
dp = new Boolean[r + 1][b + 1][max + 1][2];
ans = "";
recursion(r,b,max,0,-1,new StringBuilder());
System.out.println(ans);
}
public static void main(String[] args) throws Exception {
int tests = Integer.parseInt(br.readLine());
for (int test = 1; test <= tests; test++) {
solve();
}
}
// public static ArrayList<Integer> primes;
// public static void seive(int n){
// primes = new ArrayList<>();
// boolean[] arr = new boolean[n + 1];
// Arrays.fill(arr,true);
//
// for(int i = 2;i * i <= n;i++){
// if(arr[i]) {
// for (int j = i * i; j <= n; j += i) {
// arr[j] = false;
// }
// }
// }
// for(int i = 2;i <= n;i++) if(arr[i]) primes.add(i);
// }
// public static void sort(int[] arr){
// ArrayList<Integer> temp = new ArrayList<>();
// for(int val : arr) temp.add(val);
//
// Collections.sort(temp);
//
// for(int i = 0;i < arr.length;i++) arr[i] = temp.get(i);
// }
// public static void sort(long[] arr){
// ArrayList<Long> temp = new ArrayList<>();
// for(long val : arr) temp.add(val);
//
// Collections.sort(temp);
//
// for(int i = 0;i < arr.length;i++) arr[i] = temp.get(i);
// }
//
// public static long power(long a,long b,long mod){
// if(b == 0) return 1;
//
// long p = power(a,b / 2,mod);
// p = (p * p) % mod;
//
// if(b % 2 == 1) return (p * a) % mod;
// return p;
// }
// public static long modDivide(long a,long b,long mod){
// return ((a % mod) * (power(b,mod - 2,mod) % mod)) % mod;
// }
//
// public static int GCD(int a,int b){
// return b == 0 ? a : GCD(b,a % b);
// }
// public static long GCD(long a,long b){
// return b == 0 ? a : GCD(b,a % b);
// }
//
// public static int LCM(int a,int b){
// return a * b / GCD(a,b);
// }
// public static long LCM(long a,long b){
// return a * b / GCD(a,b);
// }
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 4fdeb32572a73d703b8ab6679b888db1 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class E {
public static HashMap<Long, Long> sortByValue(HashMap<Long, Long> hm)
{
List<Map.Entry<Long, Long> > list =
new LinkedList<Map.Entry<Long, Long> >(hm.entrySet());
Collections.sort(list, new Comparator<Map.Entry<Long, Long> >() {
public int compare(Map.Entry<Long, Long> o1,
Map.Entry<Long, Long> o2)
{
return (o1.getValue()).compareTo(o2.getValue());
}
});
HashMap<Long, Long> temp = new LinkedHashMap<Long, Long>();
for (Map.Entry<Long, Long> aa : list) {
temp.put(aa.getKey(), aa.getValue());
}
return temp;
}
static int binarySearch(ArrayList<Integer> arr, int l, int r, int x)
{
while (l <= r) {
int m = l + (r - l) / 2;
// Check if x is present at mid
if (arr.get(m) == x)
return m;
// If x greater, ignore left half
if (arr.get(m) < x)
l = m + 1;
// If x is smaller, ignore right half
else
r = m - 1;
}
// if we reach here, then element was
// not present
return l;
}
static int binarySearch1(ArrayList<Integer> arr, int l, int r, int x)
{
while (l <= r) {
int m = l + (r - l) / 2;
// Check if x is present at mid
if (arr.get(m) == x)
return m;
// If x greater, ignore left half
if (arr.get(m) < x)
l = m + 1;
// If x is smaller, ignore right half
else
r = m - 1;
}
// if we reach here, then element was
// not present
return l-1;
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
StringBuilder sb = new StringBuilder();
while(t-->0) {
int n = sc.nextInt();
int r =sc.nextInt();
int b = sc.nextInt();
String res ="";
ArrayList<String> red = new ArrayList<String> ();
ArrayList<String> blue = new ArrayList<String> ();
for(int i=0;i<b+1;i++)
red.add("R");
for(int i=0;i<b;i++)
blue.add("B");
int rem = r-(b+1);
for(int i=0;;i++) {
if(rem==0)
break;
if(i==red.size())
i=0;
String abc = red.get(i);
abc=abc+"R";
red.remove(i);
red.add(i, abc);
--rem;
}
for(int i=0;i<blue.size();i++) {
res=res+red.get(i);
res=res+blue.get(i);
}
res=res+red.get(red.size()-1);
// int a = b+1;
// int mod = (int)Math.ceil((double)r/(double)a);
// String res="";
// for(int i=0;i<b;i++) {
// res=res+"RB";
// }
// String str = "R";
// if(n%2==0) {
// String repeated = new String(new char[mod-1]).replace("\0", str);
//
// String repeated1 = new String(new char[mod-1]).replace("\0", str);
// res = repeated+res+repeated1;
// }
// else {
// String repeated = new String(new char[mod-1]).replace("\0", str);
//
// String repeated1 = new String(new char[mod]).replace("\0", str);
// res = repeated+res+repeated1;
// }
//
sb.append(res+"\n");
}
System.out.println(sb.toString());
}
private static String func(String string, int i) {
String res ="";
res = string +" "+ (i+1) +" "+ string;
return res;
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 8f0c63f48d945a2da88837f0842c12ab | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Random;
import java.util.StringTokenizer;
import java.lang.Math;
public class A {
public static void main(String[] args) {
FastScanner fs=new FastScanner();
PrintWriter out=new PrintWriter(System.out);
int T=fs.nextInt();
for (int tt=0; tt<T; tt++) {
int n=fs.nextInt();
int r=fs.nextInt();
int b=fs.nextInt();
double d = ((r * 1.0) / (b+1));
int gap = (int)Math.ceil(d);
StringBuilder ans = new StringBuilder();
int i=0;
int totr = 0, totb = 0;
while (i <n) {
int k=0;
while (k<gap && totr<r) {
ans.append("R");
k++;
i++;
totr++;
if (i==n) break;
}
if (i==n)
break;
ans.append("B");
i++;
totb++;
d = ((r - totr * 1.0) / (b-totb+1));
gap = (int)Math.ceil(d);
}
System.out.println(ans);
}
}
static final Random random=new Random();
static final int mod=1_000_000_007;
static void ruffleSort(int[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi=random.nextInt(n), temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static long add(long a, long b) {
return (a+b)%mod;
}
static long sub(long a, long b) {
return ((a-b)%mod+mod)%mod;
}
static long mul(long a, long b) {
return (a*b)%mod;
}
static long exp(long base, long exp) {
if (exp==0) return 1;
long half=exp(base, exp/2);
if (exp%2==0) return mul(half, half);
return mul(half, mul(half, base));
}
static long[] factorials=new long[2_000_001];
static long[] invFactorials=new long[2_000_001];
static void precompFacts() {
factorials[0]=invFactorials[0]=1;
for (int i=1; i<factorials.length; i++) factorials[i]=mul(factorials[i-1], i);
invFactorials[factorials.length-1]=exp(factorials[factorials.length-1], mod-2);
for (int i=invFactorials.length-2; i>=0; i--)
invFactorials[i]=mul(invFactorials[i+1], i+1);
}
static long nCk(int n, int k) {
return mul(factorials[n], mul(invFactorials[k], invFactorials[n-k]));
}
static void sort(int[] a) {
ArrayList<Integer> l=new ArrayList<>();
for (int i:a) l.add(i);
Collections.sort(l);
for (int i=0; i<a.length; i++) a[i]=l.get(i);
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
long nextLong() {
return Long.parseLong(next());
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 8039a8a32b4a94bc15fdab4b34b62ae7 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.lang.*;
import java.util.*;
public class Main {
public static int mod = (int)1e9 + 7;
// **** -----> Disjoint Set Union(DSU) Start **********
public static int findPar(int node, int[] parent) {
if (parent[node] == node)
return node;
return parent[node] = findPar(parent[node], parent);
}
public static boolean union(int u, int v, int[] rank, int[] parent) {
u = findPar(u, parent);
v = findPar(v, parent);
if(u == v) return false;
if (rank[u] < rank[v])
parent[u] = v;
else if (rank[u] > rank[v])
parent[v] = u;
else {
parent[u] = v;
rank[v]++;
}
return true;
}
// **** DSU Ends ***********
//Pair with int int
public static class Pair{
public int a;
public int b;
Pair(int a , int b){
this.a = a;
this.b = b;
}
@Override
public String toString(){
return a + " -> " + b;
}
}
public static String toBinary(int decimal) {StringBuilder sb = new StringBuilder();while (decimal > 0) {sb.append(decimal % 2);decimal = decimal / 2;}return sb.reverse().toString();}
public static boolean isPalindrome(String s) {int i = 0, j = s.length() - 1;while (i < j) {if (s.charAt(i) != s.charAt(j))return false;i++;j--;}return true;}
public static boolean isPalindrome(int[] arr) {int i = 0, j = arr.length - 1;while (i < j) {if (arr[i] != arr[j])return false;}return true;}
public static int pow(int x, int y) {int res = 1;x = x % mod;if (x == 0)return 0;while (y > 0) {if ((y & 1) != 0)res = (res * x) % mod;y = y >> 1;x = (x * x) % mod;}return res;}
public static int gcd(int a, int b) {if (b == 0)return a;return gcd(b, a % b);}
public static long gcd(long a, long b) {if (b == 0)return a;return gcd(b, a % b);}
public static void sort(long[] a) {Random rnd = new Random();for (int i = 0; i < a.length; i++) {int pos = i + rnd.nextInt(a.length - i);long temp = a[i];a[i] = a[pos];a[pos] = temp;}Arrays.sort(a);}
public static void reverse(int a[]) {int i, k, t, n = a.length;for (i = 0; i < n / 2; i++) {t = a[i];a[i] = a[n - i - 1];a[n - i - 1] = t;}}
public static void sort(int[] a) {Random rnd = new Random();for (int i = 0; i < a.length; i++) {int pos = i + rnd.nextInt(a.length - i);int temp = a[i];a[i] = a[pos];a[pos] = temp;}Arrays.sort(a);}
public static void revSort(int[] a) {Random rnd = new Random();for (int i = 0; i < a.length; i++) {int pos = i + rnd.nextInt(a.length - i);int temp = a[i];a[i] = a[pos];a[pos] = temp;}Arrays.sort(a);reverse(a);}
public static long LCM(long a, long b) {if (a > b) {long t = a;a = b;b = t;}a /= gcd(a, b);return (a * b);}
public static int findMax(int[] a, int left, int right) {int res = left;int max = a[left];for (int i = left + 1; i <= right; i++) {if (a[i] > max) {max = a[i];res = i;}}return res;}
public static long findClosest(long arr[], long target) {int n = arr.length;if (target <= arr[0])return arr[0];if (target >= arr[n - 1])return arr[n - 1];int i = 0, j = n, mid = 0;while (i < j) {mid = (i + j) / 2;if (arr[mid] == target)return arr[mid];if (target < arr[mid]) {if (mid > 0 && target > arr[mid - 1])return getClosest(arr[mid - 1], arr[mid], target);j = mid;} else {if (mid < n - 1 && target < arr[mid + 1])return getClosest(arr[mid], arr[mid + 1], target);i = mid + 1;}}return arr[mid];}
public static long getClosest(long val1, long val2, long target) {if (target - val1 >= val2 - target)return val2;else return val1;}
public static int findClosest(int arr[], int target) { int n = arr.length; if (target <= arr[0]) return arr[0]; if (target >= arr[n - 1]) return arr[n - 1]; int i = 0, j = n, mid = 0; while (i < j) { mid = (i + j) / 2; if (arr[mid] == target) return arr[mid];if (target < arr[mid]) {if (mid > 0 && target > arr[mid - 1])return getClosest(arr[mid - 1], arr[mid], target);j = mid;} else {if (mid < n - 1 && target < arr[mid + 1])return getClosest(arr[mid], arr[mid + 1], target);i = mid + 1;}}return arr[mid];}
public static int getClosest(int val1, int val2, int target) {if (target - val1 >= val2 - target)return val2;else return val1;}
public static String reverse(String str) {String nstr = "";char ch;for (int i = 0; i < str.length(); i++) {ch = str.charAt(i);nstr = ch + nstr;}return nstr;}
public static boolean isPrime(int n){if (n <= 1)return false;if (n <= 3)return true;if (n % 2 == 0 || n % 3 == 0)return false;for (int i = 5; i * i <= n; i = i + 6)if (n % i == 0 || n % (i + 2) == 0)return false;return true;}
public static int xorSum(int arr[], int n){int bits = 0;for (int i = 0; i < n; ++i)bits |= arr[i];int ans = bits * (int)Math.pow(2, n-1);return ans;}
public static ArrayList<Integer> primeFactors(int n) { ArrayList<Integer> res = new ArrayList<>();while (n%2 == 0) { res.add(2); n = n/2; } for (int i = 3; i <= Math.sqrt(n); i = i+2) { while (n%i == 0) { res.add(i); n = n/i; } } if (n > 2) res.add(n);return res;}
public static ArrayList<Long> primeFactors(long n) { ArrayList<Long> res = new ArrayList<>();while (n%2 == 0) { res.add(2L); n = n/2; } for (long i = 3; i <= Math.sqrt(n); i = i+2) { while (n%i == 0) { res.add(i); n = n/i; } } if (n > 2) res.add(n);return res;}
static int lower_bound(int array[], int low, int high, int key){
int mid;
while (low < high) {
mid = low + (high - low) / 2;
if (key <= array[mid]) high = mid;
else low = mid + 1;
}
if (low < array.length && array[low] < key) low++;
return low;
}
/********************************* Start Here ***********************************/
// int mod = 1000000007;
static HashMap<Character, TreeSet<Integer>> map;
public static void main(String[] args) throws java.lang.Exception {
if (System.getProperty("ONLINE_JUDGE") == null) {
PrintStream ps = new PrintStream(new File("output.txt"));
System.setOut(ps);
}
FastScanner sc = new FastScanner("input.txt");
StringBuilder result = new StringBuilder();
// sieveOfEratosthenes(1000000);
int T = sc.nextInt();
// int T = 1;
for(int test = 1; test <= T; test++){
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
StringBuilder sb = new StringBuilder();
if(b == 1){
for(int i = 0; i < n; i++){
if(i == n/2) sb.append('B');
else sb.append('R');
}
result.append(sb+"\n");
continue;
}
ArrayList<StringBuilder> res = new ArrayList<>();
for(int i = 0; i <= b; i++){
res.add(new StringBuilder(""));
}
int i = 0;
while(r > 0){
res.get(i).append('R');
i++;
if(i == b+1) i = 0;
r--;
}
for(i = 0; i < res.size()-1; i++)
result.append(res.get(i)+"B");
result.append(res.get(res.size()-1));
result.append("\n");
}
System.out.println(result);
System.out.close();
}
public static int solve(int n){
int mod = 32768;
int min = mod;
for(int i = 0; i <= 30; i++){
int tmp = (i+n)%mod;
int cur = i;
while(tmp != 0){
tmp = (2*tmp)%mod;
cur++;
}
min = Math.min(min, cur);
}
return min;
}
// static void sieveOfEratosthenes(int n){
// boolean prime[] = new boolean[n + 1];
// for (int i = 0; i <= n; i++)
// prime[i] = true;
// for (int p = 2; p * p <= n; p++){
// if (prime[p] == true){
// for (int i = p * p; i <= n; i += p)
// prime[i] = false;
// }
// }
// for (int i = 2; i <= n; i++){
// if (prime[i] == true)
// set.add(i);
// }
// }
public static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner(String s) {
try {
br = new BufferedReader(new FileReader(s));
} catch (FileNotFoundException e) {
br = new BufferedReader(new InputStreamReader(System.in));
}
}
String nextToken() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
return st.nextToken();
}
public String nextLine() {
if (st == null || !st.hasMoreTokens()) {
try {
return br.readLine();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return st.nextToken("\n");
}
public String[] readStringArray(int n) {
String[] a = new String[n];
for (int i = 0; i < n; i++) {
a[i] = next();
}
return a;
}
int nextInt() {
return Integer.parseInt(nextToken());
}
String next() {
return nextToken();
}
long nextLong() {
return Long.parseLong(nextToken());
}
double nextDouble() {
return Double.parseDouble(nextToken());
}
int[] readArray(int n) {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
long[] readLongArray(int n) {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
int[][] read2dArray(int n, int m) {
int[][] a = new int[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j] = nextInt();
}
}
return a;
}
long[][] read2dlongArray(int n, int m) {
long[][] a = new long[n][m];
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
a[i][j] = nextLong();
}
}
return a;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 3c4be4aa144268e98372301039ca2b28 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
public class Test
{
final static FastReader fr = new FastReader();
final static PrintWriter out = new PrintWriter(System.out) ;
static long mod = (long)1e9 + 7 ;
static long[] dp;
static void solve()
{
long n =fr.nextLong() , r = fr.nextLong(), b =fr.nextLong() ;
long x = r/(b+1) ;
StringBuilder sb =new StringBuilder("") ;
long extras = r%(b+1) ;
for (int i = 0; i < b ; i++)
{
for (int j = 0; j < x; j++) {
r-- ;
sb.append("R") ;
}
if (extras > 0) {
r-- ;
sb.append("R") ;
extras-- ;
}
sb.append("B") ;
}
while (r > 0){
r-- ;
sb.append("R") ;
}
out.println(sb);
}
public static void main(String[] args)
{
int testCases = 1;
testCases = fr.nextInt() ;
while (testCases-- > 0)
{
solve() ;
}
out.close() ;
}
static long getMax(long ... a)
{
long max = Long.MIN_VALUE ;
for (long x : a) max = Math.max(x, max) ;
return max ;
}
static long getMin(long ... a)
{
long max = Long.MAX_VALUE ;
for (long x : a) max = Math.min(x, max) ;
return max ;
}
static long fastPower(double a, long b)
{
double ans = 1 ;
while (b > 0)
{
if ((b & 1) != 0) ans *= a ;
a *= a ;
b >>= 1 ;
}
return (long)(ans + 0.5) ;
}
static long fastPower(long a, long b, long mod)
{
long ans = 1 ;
while (b > 0)
{
if ((b&1) != 0) ans = (ans%mod * a%mod) %mod;
b >>= 1 ;
a = (a%mod * a%mod)%mod ;
}
return ans ;
}
static int lower_bound(List<Integer> arr, int key)
{
int pos = Collections.binarySearch(arr, key) ;
if (pos < 0)
{
pos = - (pos + 1) ;
}
return pos ;
}
static int upper_bound(List<Integer> arr, int key)
{
int pos = Collections.binarySearch(arr, key);
pos++ ;
if (pos < 0)
{
pos = -(pos) ;
}
return pos ;
}
static int upper_bound(int arr[], int key)
{
int start = 0 , end = arr.length - 1 ;
int ans = -1 ;
while (start <= end)
{
int mid = start + ((end - start) >> 1) ;
if (arr[mid] == key) ans = mid ;
if (arr[mid] <= key) start = mid + 1 ;
else end = mid-1 ;
}
return ans ;
}
static int lower_bound(int arr[], int key)
{
int start = 0 , end = arr.length -1;
int ans = -1 ;
while (start <= end)
{
int mid = start + ((end - start )>>1) ;
if (arr[mid] == key) {
ans = mid ;
}
if (arr[mid] >= key){
end = mid - 1 ;
}
else start = mid + 1 ;
}
return ans ;
}
static class Pair{
long x;
long y ;
Pair(long x, long y){
this.x = x ;
this.y= y ;
}
}
static long gcd(long a, long b)
{
if (b == 0) return a ;
return gcd(b, a%b) ;
}
static long lcm(long a, long b)
{
long lcm = a/gcd(a, b)*b ;
return lcm ;
}
static boolean isVowel(char ch)
{
return ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u';
}
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 5fcefc42822b40e44bca4bd2990a760d | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | //package MyPackage;
import java.util.*;
import java.io.*;
public class codec{
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
String next(){
while(st==null || !st.hasMoreTokens()){
try {
st=new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt(){
return Integer.parseInt(next());
}
long nextLong(){
return Long.parseLong(next());
}
double nextDouble(){
return Double.parseDouble(next());
}
String nextLine(){
String str="";
try {
str=br.readLine().trim();
} catch (Exception e) {
e.printStackTrace();
}
return str;
}
}
static class FastWriter {
private final BufferedWriter bw;
public FastWriter() {
this.bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
public void print(Object object) throws IOException {
bw.append("" + object);
}
public void println(Object object) throws IOException {
print(object);
bw.append("\n");
}
public void close() throws IOException {
bw.close();
}
}
static long gcd(long a, long b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
static long lcm(long a, long b)
{
return (a / gcd(a, b)) * b;
}
static long pt(long v)
{
int i = 0;
while((1 << i) < v)
{
i++;
}
if((1 << i) > v) i--;
return i;
}
public static void main(String[] args) {
try {
FastReader in=new FastReader();
FastWriter out = new FastWriter();
StringBuilder res = new StringBuilder();
int testCases=in.nextInt();
while(testCases-- > 0){
// write code here
int n = in.nextInt();
int r = in.nextInt();
int b = in.nextInt();
b++;
int ans = r / b;
if(r % b != 0)
ans++;
StringBuilder sb = new StringBuilder();
b--;
int f = 0;
while(r > 0 || b > 0)
{
if(r > 0)
{
for(int i = 0; i < Math.min(ans, r); i++)
{
sb.append("R");
}
r -= Math.min(ans, r);
}
if(b > 0)
{
sb.append("B");
b--;
}
if(r - b <= 1)
{
f = 1;
break;
}
}
while(r > 0 || b > 0)
{
if(r > 0)
{
sb.append("R");
r--;
}
if(b > 0)
{
sb.append("B");
b--;
}
}
res.append(sb + "\n");
}
out.println(res);
out.close();
} catch (Exception e) {
return;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 51131dfd4ba1831c24f395fd12f79d82 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class Solution {
public static void main (String[] args)
{
Scanner s = new Scanner(System.in);
int t=s.nextInt();
while(t-->0) {
int n= s.nextInt();
int r= s.nextInt();
int b= s.nextInt();
int div= r/(b+1);
int rem= r%(b+1);
StringBuilder sb= new StringBuilder("");
while(r>0 || b>0) {
for(int i=0; i<div; i++) {
if(r>0) {
sb.append("R");
r--;
}
}
if(rem>0) {
sb.append("R");
r--;
rem--;
}
if(b>0) {
sb.append("B");
b--;
}
}
System.out.println(sb);
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | d8d7c9bc5cbf247523d743cbfd7361f3 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class ac{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
// int i=0;
b++;
String s="";
int f=r/(b);
// System.out.println(f);
int p=r-f*b;
// System.out.println(p);
for(int i=0;i<p;i++) {
int j=0;
while(j<f+1) {
s+="R";
j++;
}
s+="B";
}
p=(f+1)*b-r;
for(int i=0;i<p-1;i++) {
int j=0;
while(j<f) {
s+="R";
j++;
}
s+="B";
}
for(int i=0;i<f;i++) {
s+="R";
}
System.out.println(s);
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 11 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | feceb0927feabab6330c33882744d6bb | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
//import javafx.util.*;
public class Main
{
static PrintWriter out = new PrintWriter(System.out);
static FastReader in = new FastReader();
static int INF = Integer.MAX_VALUE;
static int NINF = Integer.MIN_VALUE;
public static void main (String[] args) throws java.lang.Exception
{
//check if you have to take product or the constraints are big
int t = i();
while(t-- > 0){
int n = i();
int r = i();
int b = i();
int max = r/(b + 1);
int rem = r%(b + 1);
String ans = "";
int ca = 0;
int cb = 0;
while(ca < r){
for(int i = 0;i < max;i++){
ans += 'R';
}
ca += max;
if(rem > 0){
ans += 'R';
ca += 1;
rem -= 1;
}
if(cb < b){
ans += 'B';
cb++;
}
}
out.println(ans);
}
out.close();
}
public static int solve(String s){
int ans = -1;
int count = 0;
int n = s.length();
for(int i = 0;i < n;i++){
if(s.charAt(i) == 'R'){
count++;
}else{
ans = Math.max(ans,count);
count = 0;
}
}
ans = Math.max(ans,count);
return ans;
}
public static void sort(int[] arr){
ArrayList<Integer> ls = new ArrayList<>();
for(int x : arr){
ls.add(x);
}
Collections.sort(ls);
for(int i = 0;i < arr.length;i++){
arr[i] = ls.get(i);
}
}
static int i()
{
return in.nextInt();
}
static long l()
{
return in.nextLong();
}
static int[] input(int N){
int A[]=new int[N];
for(int i=0; i<N; i++)
{
A[i]=in.nextInt();
}
return A;
}
static long[] inputLong(int N) {
long A[]=new long[N];
for(int i=0; i<A.length; i++)A[i]=in.nextLong();
return A;
}
}
class Pair implements Comparable<Pair>{
int x;
int y;
Pair(int x, int y){
this.x = x;
this.y = y;
}
@Override
public int compareTo(Pair obj)
{
// we sort objects on the basis of Student Id
return (this.x - obj.x);
}
}
class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br=new BufferedReader(new InputStreamReader(System.in));
}
String next()
{
while(st==null || !st.hasMoreElements())
{
try
{
st=new StringTokenizer(br.readLine());
}
catch(IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str="";
try
{
str=br.readLine();
}
catch (IOException e)
{
e.printStackTrace();
}
return str;
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 1c182b9af729c93a4814b2ff16bc7259 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class RedVersusBlue {
public static void main(String[] args) throws IOException{
Scanner sc = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt(), r = sc.nextInt() , b = sc.nextInt();
int x = r/(b+1) , y = r%(b+1);
StringBuilder res = new StringBuilder();
while (r>0){
int tmp = x;
while(tmp > 0){
res.append('R');
tmp--;
r--;
}
if(y > 0){
res.append('R');
r--;
y--;
}
if(b > 0) {
res.append('B');
b--;
}
}
pw.println(res);
}
pw.flush();
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(String file) throws IOException {
br = new BufferedReader(new FileReader(file));
}
public Scanner(FileReader r) {
br = new BufferedReader(r);
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public String readAllLines(BufferedReader reader) throws IOException {
StringBuilder content = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
content.append(line);
content.append(System.lineSeparator());
}
return content.toString();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public long[] nextlongArray(int n) throws IOException {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public Long[] nextLongArray(int n) throws IOException {
Long[] a = new Long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public int[] nextIntArray(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public Integer[] nextIntegerArray(int n) throws IOException {
Integer[] a = new Integer[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public boolean ready() throws IOException {
return br.ready();
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 5cd8fadc60051086aa8f89142ce2cfeb | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
/**
*
* @author eslam
*/
public class IceCave {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
static FastReader input = new FastReader();
static BufferedWriter log = new BufferedWriter(new OutputStreamWriter(System.out));
public static void main(String[] args) throws IOException {
int t = input.nextInt();
while (t-- > 0) {
int n = input.nextInt();
int r = input.nextInt();
int b = input.nextInt();
int e = (r - 1) - b;
int x = e / (b + 1);
e %= (b + 1);
while (n > 0) {
if (r > 0) {
log.write("R");
r--;
n--;
for (int i = 0; i < x && r > 0; i++) {
log.write("R");
n--;
r--;
}
if(e>0&&r>0){
log.write("R");
e--;
r--;
n--;
}
}
if (b > 0) {
log.write("B");
b--;
n--;
}
}
log.write("\n");
}
log.flush();
}
public static long binaryToDecimal(String w) {
long r = 0;
long l = 0;
for (int i = w.length() - 1; i > -1; i--) {
long x = (w.charAt(i) - '0') * (long) Math.pow(2, l);
r = r + x;
l++;
}
return r;
}
public static String decimalToBinary(long n) {
String w = "";
while (n > 0) {
w = n % 2 + w;
n /= 2;
}
return w;
}
public static boolean isSorted(int[] a) {
for (int i = 0; i < a.length - 1; i++) {
if (a[i] > a[i + 1]) {
return false;
}
}
return true;
}
public static void print(int a[]) throws IOException {
for (int i = 0; i < a.length; i++) {
log.write(a[i] + " ");
}
log.write("\n");
}
public static void read(int[] a) {
for (int i = 0; i < a.length; i++) {
a[i] = input.nextInt();
}
}
static class pair {
int x;
int y;
public pair(int x, int y) {
this.x = x;
this.y = y;
}
public String toString() {
return x + " " + y;
}
}
public static long LCM(long x, long y) {
return (x * y) / GCD(x, y);
}
public static long GCD(long x, long y) {
if (y == 0) {
return x;
}
return GCD(y, x % y);
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 8e1c56570719183f78ddbb380ed22976 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class RedVsBlue {
public static void main(String[] args) throws IOException {
FastScanner in = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
for (int i = 0; i < t; i++) {
int n = in.nextInt();
int r = in.nextInt();
int b = in.nextInt();
int maxCount = 1;
int numMaxCount = 0;
boolean rMore = false;
boolean bothEqual = false;
if (r > b) {
// r = numMaxCount * maxCount + (b + 1 - numMaxCount) * (maxCount - 1)
// r = (b + 1) * maxCount - b - 1 + numMaxCount
maxCount = (int) Math.ceil((double) r / ((double) b + 1));
numMaxCount = r + b + 1 - (b + 1) * maxCount;
rMore = true;
}
else if (b > r) {
maxCount = (int) Math.ceil((double) b / ((double) r + 1));
numMaxCount = b + r + 1 - (r + 1) * maxCount;
}
else {
bothEqual = true;
}
char[] c = new char[n];
if (bothEqual) {
for (int j = 0; j < n; j++) {
if (j % 2 == 0) {
c[j] = 'R';
}
else {
c[j] = 'B';
}
}
}
else {
for (int j = 0; j < Math.min(n, numMaxCount * (maxCount + 1)); j++) {
if (rMore) {
if (j % (maxCount + 1) == maxCount) {
c[j] = 'B';
}
else {
c[j] = 'R';
}
}
else {
if (j % (maxCount + 1) == maxCount) {
c[j] = 'R';
}
else {
c[j] = 'B';
}
}
}
for (int j = numMaxCount * (maxCount + 1); j < n; j++) {
if (rMore) {
if ((j - numMaxCount * (maxCount + 1)) % maxCount == maxCount - 1) {
c[j] = 'B';
}
else {
c[j] = 'R';
}
}
else {
if ((j - numMaxCount * (maxCount + 1)) % maxCount == maxCount - 1) {
c[j] = 'R';
}
else {
c[j] = 'B';
}
}
}
}
out.println(new String(c));
}
out.close();
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
// noop
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 60d0e8467c0481634abea424986cf12a | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes |
import java.util.*;
import java.lang.Math.*;
public class Inheritance{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int t=s.nextInt();
while(t-->0)
{
int n=s.nextInt();
int r=s.nextInt();
int b=s.nextInt();
int p=r/(b+1);
int q=r%(b+1);
for(int i=0;i<q;i++)
{
for(int i1=1;i1<=p+1;i1++)
{
System.out.print("R");
}
System.out.print("B");
}
for(int i=q;i<b;i++)
{
for(int i1=1;i1<=p;i1++)
{
System.out.print("R");
}
System.out.print("B");
}
for(int i1=1;i1<=p;i1++)
{
System.out.print("R");
}
System.out.println();
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 98c70166c1edb33a818614e0b635f153 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static long factorial(int number) {
long f = 1;
int j = 1;
while (j <= number) {
f = (f * j) % 998244353;
j++;
}
return f;
}
public static long combination(int n, int r) {
return factorial(n) / (factorial(n - r) * factorial(r));
}
public static void main(String[] args) throws Exception {
int t = sc.nextInt();
while(t-->0) {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
int diff = (r/(b+1));
int remain = (r%(b+1));
StringBuilder R = new StringBuilder();
while(R.length()<diff) R.append("R");
StringBuilder ans = new StringBuilder();
int ctra=0,ctrb=0;
while(ctra<r) {
ans.append(R);
ctra+=diff;
if(remain>0) {
ans.append("R");
ctra++;
remain--;
}
if(ctrb<b) {
ans.append("B");
ctrb++;
}
}
pw.println(ans);
}
pw.flush();
}
static class SegmentTree {
int[] arr, sTree, lazy;
int N;
public SegmentTree(int[] in) {
arr = in;
N = in.length - 1;
sTree = new int[2 * N];
lazy = new int[2 * N];
build(1, 1, N);
}
public void build(int Node, int left, int right) { // O(n)
if (left == right)
sTree[Node] = arr[left];
else {
int r = 2 * Node + 1;
int l = 2 * Node;
int mid = (left + right) / 2;
build(l, left, mid);
build(r, mid + 1, right);
sTree[Node] = sTree[l] + sTree[r];
}
}
public int query(int i, int j) {
return query(1, 1, N, i, j);
}
public int query(int Node, int left, int right, int i, int j) {
if (right < i || left > j)
return 0;
if (right <= j && i <= left) {
return sTree[Node];
}
int mid = (left + right) / 2;
int l = 2 * Node;
int r = 2 * Node + 1;
return query(l, left, mid, i, j) + query(r, mid + 1, right, i, j);
}
public void updatePoint(int idx, int value) {
int node = idx + N - 1;
arr[idx] = value;
sTree[node] = value;
while (node > 1) {
node /= 2;
int l = 2 * node;
int r = 2 * node + 1;
sTree[node] = sTree[l] + sTree[r];
}
}
public void updateRange(int i, int j, int val) {
updateRange(1, 1, N, i, j, val);
}
public void updateRange(int Node, int left, int right, int i, int j, int val) {
if (i > right || left > j)
return;
if (right <= j && i <= left) {
sTree[Node] += val * (right - left + 1);
lazy[Node] += val;
} else {
int l = 2 * Node;
int r = 2 * Node + 1;
int mid = (left + right) / 2;
propagate(Node, left, right);
updateRange(l, left, mid, i, j, val);
updateRange(r, mid + 1, right, mid, j, val);
sTree[Node] = sTree[l] + sTree[r];
}
}
public void propagate(int node, int left, int right) {
int l = 2 * node;
int r = 2 * node + 1;
int mid = (left + right) / 2;
lazy[l] = lazy[node];
lazy[r] = lazy[node];
sTree[l] += lazy[node] * (mid - left + 1);
sTree[r] += lazy[node] * (right - mid);
lazy[node] = 0;
}
}
public static void sort(int[] in) {
shuffle(in);
Arrays.sort(in);
}
public static void shuffle(int[] in) {
for (int i = 0; i < in.length; i++) {
int idx = (int) (Math.random() * in.length);
int tmp = in[i];
in[i] = in[idx];
in[idx] = tmp;
}
}
static class Pair implements Comparable<Pair> {
int x;
int y;
public Pair(int x, int y) {
this.x = x;
this.y = y;
}
public int compareTo(Pair o) {
return x - o.x;
}
public String toString() {
return x + " " + y;
}
}
static Scanner sc = new Scanner(System.in);
static PrintWriter pw = new PrintWriter(System.out);
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(FileReader r) {
br = new BufferedReader(r);
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public long[] nextlongArray(int n) throws IOException {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public Long[] nextLongArray(int n) throws IOException {
Long[] a = new Long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public int[] nextIntArray(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public Integer[] nextIntegerArray(int n) throws IOException {
Integer[] a = new Integer[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public boolean ready() throws IOException {
return br.ready();
}
}
public static void display(char[][] a) {
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < a[i].length; j++) {
System.out.print(a[i][j]);
}
System.out.println();
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 6d46344e947c0d4f87a3b88c6d10ffcb | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
public class _7_Red_Vs_Blue {
public static void main(String args[]){
Scanner sc=new Scanner(System.in);
int test=Integer.parseInt(sc.nextLine());
for(int i=0;i<test;i++)
{
String input[]=sc.nextLine().split(" ");
int n=Integer.parseInt(input[0]);
int r=Integer.parseInt(input[1]);
int b=Integer.parseInt(input[2]);
int calc=n/(b+1);
int rem=0;
//System.out.println(rem);
if(n%(b+1)!=0)
{
rem=b-(r/calc);
calc++;
}
String s="";
if(rem>0){
b=b-rem;}
//System.out.println(b);
for(int j=0;j<n-rem;j++){
if(b!=0 && (j+1)%calc==0)
{
s+="B";
b--;
if(rem>0)
{
s+="B";
rem--;
}
}
else if(r!=0)
{
s+="R";
r--;
}
}
System.out.println(s);
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | c8ef71eaeef8be140284bdb16dd3c20a | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class a {
public static void main(String[] args){
FastScanner sc = new FastScanner();
int t = sc.nextInt();
while(t-- > 0){
int n = sc .nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
StringBuilder ans = new StringBuilder();
int groupSize = r/(b+1);
int largeGroups = r - (b+1)*groupSize;
int smallGroups = b+1 - largeGroups;
for(int i=0; i<largeGroups; i++){
for(int j=0; j<groupSize+1; j++){
ans.append('R');
}
ans.append('B');
}
for(int i=0; i<smallGroups; i++){
for(int j=0; j<groupSize; j++){
ans.append('R');
}
ans.append('B');
}
ans.deleteCharAt(ans.length()-1);
System.out.println(ans);
}
}
}
class FastScanner
{
//I don't understand how this works lmao
private int BS = 1 << 16;
private char NC = (char) 0;
private byte[] buf = new byte[BS];
private int bId = 0, size = 0;
private char c = NC;
private double cnt = 1;
private BufferedInputStream in;
public FastScanner() {
in = new BufferedInputStream(System.in, BS);
}
public FastScanner(String s) {
try {
in = new BufferedInputStream(new FileInputStream(new File(s)), BS);
} catch (Exception e) {
in = new BufferedInputStream(System.in, BS);
}
}
private char getChar() {
while (bId == size) {
try {
size = in.read(buf);
} catch (Exception e) {
return NC;
}
if (size == -1) return NC;
bId = 0;
}
return (char) buf[bId++];
}
public int nextInt() {
return (int) nextLong();
}
public int[] nextInts(int N) {
int[] res = new int[N];
for (int i = 0; i < N; i++) {
res[i] = (int) nextLong();
}
return res;
}
public long[] nextLongs(int N) {
long[] res = new long[N];
for (int i = 0; i < N; i++) {
res[i] = nextLong();
}
return res;
}
public long nextLong() {
cnt = 1;
boolean neg = false;
if (c == NC) c = getChar();
for (; (c < '0' || c > '9'); c = getChar()) {
if (c == '-') neg = true;
}
long res = 0;
for (; c >= '0' && c <= '9'; c = getChar()) {
res = (res << 3) + (res << 1) + c - '0';
cnt *= 10;
}
return neg ? -res : res;
}
public double nextDouble() {
double cur = nextLong();
return c != '.' ? cur : cur + nextLong() / cnt;
}
public double[] nextDoubles(int N) {
double[] res = new double[N];
for (int i = 0; i < N; i++) {
res[i] = nextDouble();
}
return res;
}
public String next() {
StringBuilder res = new StringBuilder();
while (c <= 32) c = getChar();
while (c > 32) {
res.append(c);
c = getChar();
}
return res.toString();
}
public String nextLine() {
StringBuilder res = new StringBuilder();
while (c <= 32) c = getChar();
while (c != '\n') {
res.append(c);
c = getChar();
}
return res.toString();
}
public boolean hasNext() {
if (c > 32) return true;
while (true) {
c = getChar();
if (c == NC) return false;
else if (c > 32) return true;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | b3359fcafea2556a073908b7904b52b9 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class template {
static class QuickReader
{
BufferedReader in;
StringTokenizer token;
public QuickReader(InputStream ins)
{
in=new BufferedReader(new InputStreamReader(ins));
token=new StringTokenizer("");
}
public boolean hasNext()
{
while (!token.hasMoreTokens())
{
try
{
String s = in.readLine();
if (s == null) return false;
token = new StringTokenizer(s);
} catch (IOException e)
{
throw new InputMismatchException();
}
}
return true;
}
public String next()
{
hasNext();
return token.nextToken();
}
public int nextInt()
{
return Integer.parseInt(next());
}
public int[] nextInts(int n)
{
int[] res = new int[n];
for (int i = 0; i < n; i++)
res[i] = nextInt();
return res;
}
public long nextLong() {
return Long.parseLong(next());
}
public long[] nextLongs(int n)
{
long[] res = new long[n];
for (int i = 0; i < n; i++)
res[i] = nextLong();
return res;
}
}
static class FastScanner {
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st=new StringTokenizer("");
String next() {
while (!st.hasMoreTokens())
try {
st=new StringTokenizer(br.readLine());
} catch (IOException ignored) {}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
}
private QuickReader sc;
private PrintWriter ptk;
public template(QuickReader sc, PrintWriter ptk) {
this.sc = sc;
this.ptk = ptk;
}
public static void main(String[] args) {
QuickReader in = new QuickReader(System.in);
try(PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));)
{
new template(in, out).solve();
}
}
public static String sortString(String inputString)
{
// Converting input string to character array
char tempArray[] = inputString.toCharArray();
// Sorting temp array using
Arrays.sort(tempArray);
// Returning new sorted string
return new String(tempArray);
}
public void solve() {
int t =sc.nextInt();
while (t-- > 0) {
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
while (b>0){
int k= (int) Math.ceil((double) r/(b+1));
for (int i = 0; i <k ; i++) {
System.out.print("R");
}
System.out.print("B");
b--;
r=r-k;
}
while (r>0){
System.out.print("R");
r--;
}
System.out.println();
}
}
static long lcm(int a, int b)
{
return (a / gcd(a, b)) * b;
}
private static long gcd(long a, long b)
{
if (b == 0) {
return a;
}
return gcd(b, a % b);
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | b69da635880a5056fbaee36020912d22 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
double r=sc.nextDouble();
double b=sc.nextDouble();
StringBuilder s=new StringBuilder();
int cont=0;
double r1=r,b1=b;
while(r>0){
cont=(int)Math.ceil(r/(b+1));
int c=0;
while(c<cont&& r>0){
s.append("R");
r--;
c++;
}
if(b>0){
s.append("B");
b--;
}
}//System.out.println(cont+" "+b);
while(b>0){
s.append("B");
b--;
}
System.out.println(s.toString());
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | fafa6e9b24f62620a6ac1823ac34a267 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) {
FastScanner fs = new FastScanner();
PrintWriter out = new PrintWriter(System.out);
int T = fs.nextInt();
for (int tt=0; tt<T; tt++) {
fs.nextInt();
int r = fs.nextInt();
int b = fs.nextInt();
StringBuilder sb = new StringBuilder();
while(r>0) {
if(b==0) {
for(int i=0; i<r; i++)
sb.append("R");
break;
}
String cur = build(r, b);
sb.append(cur);
r-=cur.length()-1;
b--;
}
out.println(sb);
}
out.close();
}
public static String build(int r, int b) {
StringBuilder sb = new StringBuilder();
int div = r/(b+1);
if(r%(b+1)!=0)
div++;
for(int i=0; i<div; i++)
sb.append("R");
sb.append("B");
return sb.toString();
}
static final Random random=new Random();
static void ruffleSort(int[] a) {
int n=a.length;//shuffle, then sort
for (int i=0; i<n; i++) {
int oi=random.nextInt(n), temp=a[oi];
a[oi]=a[i]; a[i]=temp;
}
Arrays.sort(a);
}
static class FastScanner {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer("");
String next() {
while (!st.hasMoreTokens()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
int[] readArray(int n) {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i]=nextInt();
return a;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 1114e65b477691c390481922d1d515f7 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | /*############################################################################################################
########################################## >>>> Diaa12360 <<<< ###############################################
########################################### Just Nothing #################################################
#################################### If You Need it, Fight For IT; #########################################
###############################################.-. 1 5 9 2 .-.################################################
############################################################################################################*/
import javax.security.auth.callback.CallbackHandler;
import java.io.*;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
public class Solution {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
// BufferedReader in = new BufferedReader(new FileReader("src/input"));
StringBuilder out = new StringBuilder();
StringTokenizer tk;
int __ = ints(in.readLine());
while (__-- > 0) {
tk = new StringTokenizer(in.readLine());
int n = ints(tk.nextToken()), r = ints(tk.nextToken()), b = ints(tk.nextToken());
int p = r / (b + 1), q = r % (b + 1);
for (int i = 0; i < q; i++) {
for (int j = 0; j < p + 1; j++) {
out.append('R');
}
out.append('B');
}
for (int i = q; i < b; i++) {
for (int j = 0; j < p; j++) {
out.append('R');
}
out.append('B');
}
for (int j = 0; j < p; j++) {
out.append('R');
}
out.append('\n');
}
System.out.println(out);
}
static int ints(String s) {
return Integer.parseInt(s);
}
static long ll(String s) {
return Long.parseLong(s);
}
static int[] readArray(String s, int n) {
StringTokenizer tk = new StringTokenizer(s);
int[] arr = new int[n];
for (int i = 0; i < n; i++)
arr[i] = ints(tk.nextToken());
return arr;
}
static int[] readArray(String s) {
StringTokenizer tk = new StringTokenizer(s);
int[] arr = new int[tk.countTokens()];
for (int i = 0; i < arr.length; i++)
arr[i] = ints(tk.nextToken());
return arr;
}
static void printArray(char[][] arr, StringBuilder out) {
out.append("YES").append('\n');
for (char[] chars : arr) {
for (char c : chars) {
out.append(c);
}
out.append('\n');
}
}
static <T, E> Map<T, E> createMapFromList(List<T> l, Function<T, E> fun) {
Map<T, E> mp = new HashMap<>();
for (T x : l) {
mp.put(x, fun.apply(x));
}
return mp;
}
}
class ArrayStack<E> {
public static final int CAPACITY = 1000;
private E[] data;
private int t = -1;
public ArrayStack() {
this(CAPACITY);
}
public ArrayStack(int capacity) {
data = (E[]) new Object[capacity];
}
public int size() {
return t + 1;
}
public boolean isEmpty() {
return t == -1;
}
public E push(E e) throws IllegalStateException {
if (size() == data.length) throw new IllegalStateException("Stack is full");
data[++t] = e;
return e;
}
public E peek() {
return isEmpty() ? null : data[t];
}
public E pop() {
if (isEmpty())
return null;
E d = data[t];
data[t] = null;
t--;
return d;
}
}
class Pair<E, T> {
E first;
T second;
Pair(E f, T s) {
first = f;
second = s;
}
public E getFirst() {
return first;
}
public T getSecond() {
return second;
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 4be95398bcd6aba8e51545d3c7877208 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main implements Runnable {
BufferedReader in;
PrintWriter out;
StringTokenizer tok = new StringTokenizer("");
public static void main(String[] args) {
new Thread(null, new Main(), "", 256 * (1L << 20)).start();
}
public void run() {
try {
long t1 = System.currentTimeMillis();
if (System.getProperty("ONLINE_JUDGE") != null) {
in = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
} else {
in = new BufferedReader(new FileReader("input.txt"));
out = new PrintWriter("output.txt");
}
Locale.setDefault(Locale.US);
solve();
in.close();
out.close();
long t2 = System.currentTimeMillis();
System.err.println("Time = " + (t2 - t1));
} catch (Throwable t) {
t.printStackTrace(System.err);
System.exit(-1);
}
}
String readString() throws IOException {
while (!tok.hasMoreTokens()) {
tok = new StringTokenizer(in.readLine());
}
return tok.nextToken();
}
int readInt() throws IOException {
return Integer.parseInt(readString());
}
long readLong() throws IOException {
return Long.parseLong(readString());
}
double readDouble() throws IOException {
return Double.parseDouble(readString());
}
void solveTest() throws IOException {
int n = readInt();
int r = readInt();
int b = readInt();
int amountR = 0;
int amountB = 0;
String[] answer = new String[n];
int counter = r / (b + 1);
// out.println(counter);
int j = 0;
boolean y = false;
for (int i = 0; i < n; i++) {
if (j == counter && amountB < b) {
answer[i] = "B";
y = true;
amountB++;
} else if (amountR < r){
answer[i] = "R";
amountR++;
} else if (amountB < b) {
answer[i] = "B";
amountB++;
}
j = j + 1;
if (y) {
j = 0;
y = false;
}
}
int rAtEnd = 0;
for (int i = answer.length - counter - 1; i >= 0; i--) {
if (answer[i].equals("R")) {
rAtEnd++;
answer[i] = "";
} else {
break;
}
}
// out.println(rAtEnd);
if (rAtEnd > 0) {
boolean f = true;
for (int i = 0; i < answer.length; i++) {
if (answer[i].equals("R") && rAtEnd > 0 && f) {
answer[i] = "RR";
f = false;
rAtEnd--;
} else if (answer[i].equals("B")){
f = true;
}
}
}
for (int i = 0; i < n; i++) {
out.print(answer[i]);
}
out.println("");
}
void solve() throws IOException {
int testCases = readInt();
for (int tests = 0; tests < testCases; tests++) {
solveTest();
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 7af662f8af0fba99d4fbf7d1607e3145 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | // Working program with FastReader
import java.io.*;
import java.util.StringTokenizer;
//
public class Example {
static BufferedWriter bw;
static {
bw = new BufferedWriter(new OutputStreamWriter(System.out));
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
public static void print(String a) throws IOException {
bw.write(a);
}
public static void printSp(String a) throws IOException {
bw.write(a + " ");
}
public static void println(String a) throws IOException {
bw.write(a + "\n");
}
static int min = Integer.MAX_VALUE;
static boolean tt = true;
static int mod = (int) (1e9 + 7);
static long minDIff = Long.MAX_VALUE;
static int[] dp;
public static void main(String[] args) throws IOException {
FastReader sc = new FastReader();
BufferedWriter print = new BufferedWriter(new OutputStreamWriter(System.out));
int t=sc.nextInt();
while (t>0){
t--;
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
int tt=(int)Math.ceil(r/((double)b+1));
StringBuilder ans= new StringBuilder();
while (r>0||b>0){
int temp=tt;
while (temp>0&& r>b){
ans.append("R");
r--;
temp--;
}
if(b>0){
ans.append("B");
b--;
}
}
System.out.println(ans);
}
}
private static boolean poss(int[] ar, long mid,int max) {
long odd=(mid+1)/2;
long even=(mid)/2;
long odd1=0;
long even1=0;
for(int a:ar){
odd1+=((max-a)%2);
even1+=((max-a)/2);
}
long req=0;
if(odd1==even1){
req= odd1+even1;
}else if(odd1>even1){
req=2*odd1-1;
}else{
req=(even1-odd1+2)/3;
req+=even1+odd1;
}
return req<=mid;
}
private static int solve1(int num) {
int c=0;
while (num%2==0){
num=num/2;
c++;
}
return c;
}
private static int solve(int[] ar, int i, int last,int index) {
if(i>=ar.length){
return 0;
}
if(dp[i]!=-1){
return dp[i];
}
if(index==0){
int ans1=1+solve(ar,i+1,ar[i],i);
int ans2=solve(ar,i+1,0,index);
return dp[i]=Math.max(ans1,ans2);
}else{
int ans2=0;
if(i%index==0&& ar[i]>last){
ans2=1+solve(ar,i+1,ar[i],i);
}
int ans3=solve(ar,i+1,last,index);
return dp[i]=Math.max(ans2,ans3);
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | eb667224bea0b91d86e856c74b3d0cc5 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class Solution {
static BufferedReader bf;
static PrintWriter out;
public static void main (String[] args)throws IOException {
bf = new BufferedReader(new InputStreamReader(System.in));
out = new PrintWriter(System.out);
int t = Integer.parseInt(bf.readLine());
while(t-->0){
solve();
}
}
public static void solve()throws IOException{
String[]temp = bf.readLine().split(" ");
int n = toInt(temp[0]);
int r = toInt(temp[1]);
int b = toInt(temp[2]);
int parts = (r/(b+1));
int remain = (r%(b+1));
int count = 0;
StringBuilder sb = new StringBuilder();
while(r > 0){
if(remain!=0){
if(count == parts+1){
sb.append("B");
remain--;
count = 0;
}
else{
sb.append("R");
count++;
r--;
}
}
else{
if(count == parts){
sb.append("B");
count = 0;
}
else{
sb.append("R");
r--;
count++;
}
}
}
println(sb.toString());
}
public static void swap(List<Integer>list,int i,int j){
int temp = list.get(i);
list.set(i,list.get(j));
list.set(j,temp);
}
public static boolean check(List<Integer>list){
if(list.get(0) == 1)return false;
int first = list.get(0) - 1;
for(int i =1;i<list.size();i++){
if(list.get(i) == i+1)return false;
first = ((list.get(i)-(i+1))^first);
}
if(first == 0)return true;
return false;
}
// code for input
public static void print(String s ){
System.out.print(s);
}
public static void print(int num ){
System.out.print(num);
}
public static void print(long num ){
System.out.print(num);
}
public static void println(String s){
System.out.println(s);
}
public static void println(int num){
System.out.println(num);
}
public static void println(long num){
System.out.println(num);
}
public static void println(){
System.out.println();
}
public static int toInt(String s){
return Integer.parseInt(s);
}
public static long toLong(String s){
return Long.parseLong(s);
}
public static String[] nextStringArray()throws IOException{
return bf.readLine().split(" ");
}
public static int nextInt()throws IOException{
return Integer.parseInt(bf.readLine());
}
public static long nextLong()throws IOException{
return Long.parseLong(bf.readLine());
}
public static String nextString()throws IOException{
return bf.readLine();
}
public static int[] nextIntArray(int n)throws IOException{
String[]str = bf.readLine().split(" ");
int[]arr = new int[n];
for(int i =0;i<n;i++){
arr[i] = Integer.parseInt(str[i]);
}
return arr;
}
public static long[] nextLongArray(int n)throws IOException{
String[]str = bf.readLine().split(" ");
long[]arr = new long[n];
for(int i =0;i<n;i++){
arr[i] = Long.parseLong(str[i]);
}
return arr;
}
public static int[][] newIntMatrix(int r,int c)throws IOException{
int[][]arr = new int[r][c];
for(int i =0;i<r;i++){
String[]str = bf.readLine().split(" ");
for(int j =0;j<c;j++){
arr[i][j] = Integer.parseInt(str[j]);
}
}
return arr;
}
public static long[][] newLongMatrix(int r,int c)throws IOException{
long[][]arr = new long[r][c];
for(int i =0;i<r;i++){
String[]str = bf.readLine().split(" ");
for(int j =0;j<c;j++){
arr[i][j] = Long.parseLong(str[j]);
}
}
return arr;
}
static class pair{
int one;
int two;
pair(int one,int two){
this.one = one ;
this.two =two;
}
}
public static long gcd(long a,long b){
if(b == 0)return a;
return gcd(b,a%b);
}
public static long lcm(long a,long b){
return (a*b)/(gcd(a,b));
}
}
// sometimes just try to think in straightforward plan in A and B problems don't always complecated the questions with thinking too much differently
// always use long number to do 10^9+7 modulo
// if a problem is related to binary string it could also be related to parenthesis
// *****try to use binary search(it is a very beautiful thing it can work in some of the very unexpected problems ) in the question it might work******
// try sorting
// try to think in opposite direction of question it might work in your way
// if a problem is related to maths try to relate some of the continuous subarray with variables like - > a+b+c+ or a,b,c,d in general
// gcd(1.p1,2.p2,3.p3,4.p4....n.pn) cannot be greater than 2 it has been proved
// if the question is to much related to left and/or right side of any element in an array then try monotonic stack it could work.
// in range query sums try to do binary search it could work | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 5252240fad73d16429b8d94648bf1935 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
public class Codeforces782_1 {
public static void main(String[] args) {
Scanner input =new Scanner(System.in);
int t=input.nextInt();
for(int i=0;i<t;i++){
int n,r,b;
n=input.nextInt();
r= input.nextInt();
b= input.nextInt();
String s="";
String x="";
int y;
if(r==1&&b==1){
s="RB";
}
else if(r==1){
y=b/2;
for(int j=0;j<y;j++){
s=s+"B";
}
s=s+"R";
for(int j=0;j<(b-y);j++){
s=s+"B";
}
}
else if(b==1){
y=r/2;
for(int j=0;j<y;j++){
s=s+"R";
}
s=s+"B";
for(int j=0;j<(r-y);j++){
s=s+"R";
}
}
else if(r==b){
for(int j=0;j<n/2;j++){
s=s+"RB";
}
}
else if(r>b){
int ay=r-(b*r/(b+1));
// System.out.println(ay);
if((r/b<=r/(b+1)||r/b<=ay)&&(r%b<=r/(b+1)||r%b<=ay)) {
// System.out.println();
x = "";
y = r / b;
for (int j = 0; j < y; j++) {
x = x + "R";
}
x = x + "B";
for (int j = 0; j < b; j++) {
s = s + x;
}
if (r % b != 0) {
for (int j = 0; j < r % b; j++) {
s = s + "R";
}
}
}
else {
int m,in1=0,in2=0;
y=r/(b+1);
m=ay;
for(int j=0;j<b+2;j++){
int sum=(j*m)+(1+b-j)*y;
// System.out.println(sum);
if(sum==r){
in1=j;
in2=1+b-j;
break;
}
}
// System.out.println(m+" "+y+" "+in1+" "+in2);
for (int j = 0; j < y; j++) {
x = x + "R";
}
x=x+"B";
for(int j=0;j<in2;j++){
s=s+x;
}
String s1="";
for(int j=0;j<m;j++){
s1=s1+"R";
}
s1=s1+"B";
for(int j=0;j<in1;j++){
s=s+s1;
}
s=s.substring(0,n);
}
}
else if(r<b){
int ay=b-(r*b/(r+1));
if((b/r<=b/(r+1)||b/r<=ay)&&b%r<=b/(r+1)||b%r<=ay) {
x = "";
y = b / r;
for (int j = 0; j < y; j++) {
x = x + "B";
}
x = x + "R";
for (int j = 0; j < b; j++) {
s = s + x;
}
if (b % r != 0) {
for (int j = 0; j < b % r; j++) {
s = s + "B";
}
}
}
else{
int in1=0,in2=0;
y=b/(r+1);
int m=ay;
for(int j=0;j<=r+2;j++){
int sum=(j*m)+(1+r-j)*y;
if(sum==b){
in1=j;
in2=1+r-j;
break;
}
}
for (int j = 0; j < y; j++) {
x = x + "B";
}
x=x+"R";
for(int j=0;j<in2;j++){
s=s+x;
}
String s1="";
for(int j=0;j<m;j++){
s1=s1+"B";
}
s1=s1+"R";
for(int j=0;j<in1;j++){
s=s+s1;
}
s.substring(0,n);
}
}
System.out.println(s);
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 9df738d0890f50929fe8302bbba878a6 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class A_1659 {
public static void main(String[] args)
{
/*
* 11 7 4
RBRBRBRBRRR
*/
FastReader sc = new FastReader();
PrintWriter out=new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
int[] arr=new int[b+1];
int b1=0;
int b2=0;
int c=1;
while(b2<r) {
if(b1==b+1) {
c++;
b1=0;
}
arr[b1]=c;
b1++;
b2++;
}
for(int i=0;i<=b;i++) {
int co=0;
while(co<arr[i]) {
out.print("R");
co++;
}
if(i!=b) out.print("B");
}
out.println();
}
out.close();
}
static class FastReader
{
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements())
{
try
{
st = new StringTokenizer(br.readLine());
}
catch (IOException e)
{
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt()
{
return Integer.parseInt(next());
}
long nextLong()
{
return Long.parseLong(next());
}
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return (str);
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 2bd2c299c8087ff42e8d1407d9567feb | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Map.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
import static java.lang.System.*;
public class Main
{
public void tq() throws Exception
{
st=new StringTokenizer(bq.readLine());
int tq=i();
sb=new StringBuilder(2000000);
o:
while(tq-->0)
{
int n=i();
int r=i();
int b=i();
String k="";
int v=r/(b+1);
char a[]=new char[n];
fill(a,'R');
int c=0;
for(int x=0;x<n;x++)
{
if(c==v)
{
a[x]='B';
c=0;
b--;
if(b==0)break;
v=r/(b+1);
}
else
{
c++;
r--;
}
}
sl(new String(a));
}
p(sb);
}
long mod=1000000007l;
int max=Integer.MAX_VALUE,min=Integer.MIN_VALUE;long maxl=Long.MAX_VALUE,minl=Long.MIN_VALUE;
BufferedReader bq = new BufferedReader(new InputStreamReader(in));StringTokenizer st;StringBuilder sb;
public static void main(String[] a)throws Exception{new Main().tq();}
int di[][]={{-1,0},{1,0},{0,-1},{0,1}};
int de[][]={{-1,0},{1,0},{0,-1},{0,1},{-1,-1},{1,1},{-1,1},{1,-1}};
void f1(int ar[],int v){fill(ar,v);}
void f2(int ar[][],int v){for(int a[]:ar)fill(a,v);}
void f1(long ar[],long v){fill(ar,v);}
void f2(long ar[][],int v){for(long a[]:ar)fill(a,v);}
void f3(long ar[][][],int v){for(long a[][]:ar)for(long b[]:a)fill(b,v);}
void f(){out.flush();}
int p(int i,int p[]){return p[i]<0?i:(p[i]=p(p[i],p));}
boolean c(int x,int y,int n,int m){return x>=0&&x<n&&y>=0&&y<m;}
void p(Object p) {out.print(p);}void pl(Object p) {out.println(p);}void pl() {out.println();}
void s(String s) {sb.append(s);}
void s(int s) {sb.append(s);}
void s(long s) {sb.append(s);}
void s(char s) {sb.append(s);}
void s(double s) {sb.append(s);}
void ss() {sb.append(' ');}
void sl(String s) {s(s);sb.append("\n");}
void sl(int s) {s(s);sb.append("\n");}
void sl(long s) {s(s);sb.append("\n");}
void sl(char s) {s(s);sb.append("\n");}
void sl(double s) {s(s);sb.append("\n");}
void sl() {sb.append("\n");}
int l(int v) {return 31 - Integer.numberOfLeadingZeros(v);}
long l(long v) {return 63 - Long.numberOfLeadingZeros(v);}
int sq(int a) {return (int) sqrt(a);}
long sq(long a) {return (long) sqrt(a);}
int gcd(int a, int b)
{
while (b > 0)
{
int c = a % b;
a = b;
b = c;
}
return a;
}
long gcd(long a, long b)
{
while (b > 0l)
{
long c = a % b;
a = b;
b = c;
}
return a;
}
boolean p(String s, int i, int j)
{
while (i < j) if (s.charAt(i++) != s.charAt(j--)) return false;
return true;
}
boolean[] si(int n)
{
boolean bo[] = new boolean[n + 1];
bo[0] = bo[1] = true;
for (int x = 4; x <= n; x += 2) bo[x] = true;
for (int x = 3; x * x <= n; x += 2)
{
if (!bo[x])
{
int vv = (x << 1);
for (int y = x * x; y <= n; y += vv) bo[y] = true;
}
}
return bo;
}
long mul(long a, long b, long m)
{
long r = 1l;
a %= m;
while (b > 0)
{
if ((b & 1) == 1) r = (r * a) % m;
b >>= 1;
a = (a * a) % m;
}
return r;
}
int i() throws IOException
{
if (!st.hasMoreTokens()) st = new StringTokenizer(bq.readLine());
return Integer.parseInt(st.nextToken());
}
long l() throws IOException
{
if (!st.hasMoreTokens()) st = new StringTokenizer(bq.readLine());
return Long.parseLong(st.nextToken());
}
String s() throws IOException
{
if (!st.hasMoreTokens()) st = new StringTokenizer(bq.readLine());
return st.nextToken();
}
double d() throws IOException
{
if (!st.hasMoreTokens()) st = new StringTokenizer(bq.readLine());
return Double.parseDouble(st.nextToken());
}
void s(int a[])
{
for (int e : a){sb.append(e);sb.append(' ');}
sb.append("\n");
}
void s(long a[])
{
for (long e : a){sb.append(e);sb.append(' ');}
sb.append("\n");
}
void s(char a[])
{
for (char e : a){sb.append(e);sb.append(' ');}
sb.append("\n");
}
void s(int ar[][]) {for (int a[] : ar) s(a);}
void s(long ar[][]) {for (long a[] : ar) s(a);}
void s(char ar[][]) {for (char a[] : ar) s(a);}
int[] ari(int n) throws IOException
{
int ar[] = new int[n];
if (!st.hasMoreTokens()) st = new StringTokenizer(bq.readLine());
for (int x = 0; x < n; x++) ar[x] = Integer.parseInt(st.nextToken());
return ar;
}
long[] arl(int n) throws IOException
{
long ar[] = new long[n];
if (!st.hasMoreTokens()) st = new StringTokenizer(bq.readLine());
for (int x = 0; x < n; x++) ar[x] = Long.parseLong(st.nextToken());
return ar;
}
char[] arc(int n) throws IOException
{
char ar[] = new char[n];
if (!st.hasMoreTokens()) st = new StringTokenizer(bq.readLine());
for (int x = 0; x < n; x++) ar[x] = st.nextToken().charAt(0);
return ar;
}
double[] ard(int n) throws IOException
{
double ar[] = new double[n];
if (!st.hasMoreTokens()) st = new StringTokenizer(bq.readLine());
for (int x = 0; x < n; x++) ar[x] = Double.parseDouble(st.nextToken());
return ar;
}
String[] ars(int n) throws IOException
{
String ar[] = new String[n];
if (!st.hasMoreTokens()) st = new StringTokenizer(bq.readLine());
for (int x = 0; x < n; x++) ar[x] = st.nextToken();
return ar;
}
int[][] ari(int n, int m) throws IOException
{
int ar[][] = new int[n][m];
for (int x = 0; x < n; x++)ar[x]=ari(m);
return ar;
}
long[][] arl(int n, int m) throws IOException
{
long ar[][] = new long[n][m];
for (int x = 0; x < n; x++)ar[x]=arl(m);
return ar;
}
char[][] arc(int n, int m) throws IOException
{
char ar[][] = new char[n][m];
for (int x = 0; x < n; x++)ar[x]=arc(m);
return ar;
}
double[][] ard(int n, int m) throws IOException
{
double ar[][] = new double[n][m];
for (int x = 0; x < n; x++)ar[x]=ard(m);
return ar;
}
void p(int ar[])
{
sb = new StringBuilder(11 * ar.length);
for (int a : ar) {sb.append(a);sb.append(' ');}
out.println(sb);
}
void p(long ar[])
{
StringBuilder sb = new StringBuilder(20 * ar.length);
for (long a : ar){sb.append(a);sb.append(' ');}
out.println(sb);
}
void p(double ar[])
{
StringBuilder sb = new StringBuilder(22 * ar.length);
for (double a : ar){sb.append(a);sb.append(' ');}
out.println(sb);
}
void p(char ar[])
{
StringBuilder sb = new StringBuilder(2 * ar.length);
for (char aa : ar){sb.append(aa);sb.append(' ');}
out.println(sb);
}
void p(String ar[])
{
int c = 0;
for (String s : ar) c += s.length() + 1;
StringBuilder sb = new StringBuilder(c);
for (String a : ar){sb.append(a);sb.append(' ');}
out.println(sb);
}
void p(int ar[][])
{
StringBuilder sb = new StringBuilder(11 * ar.length * ar[0].length);
for (int a[] : ar)
{
for (int aa : a){sb.append(aa);sb.append(' ');}
sb.append("\n");
}
p(sb);
}
void p(long ar[][])
{
StringBuilder sb = new StringBuilder(20 * ar.length * ar[0].length);
for (long a[] : ar)
{
for (long aa : a){sb.append(aa);sb.append(' ');}
sb.append("\n");
}
p(sb);
}
void p(double ar[][])
{
StringBuilder sb = new StringBuilder(22 * ar.length * ar[0].length);
for (double a[] : ar)
{
for (double aa : a){sb.append(aa);sb.append(' ');}
sb.append("\n");
}
p(sb);
}
void p(char ar[][])
{
StringBuilder sb = new StringBuilder(2 * ar.length * ar[0].length);
for (char a[] : ar)
{
for (char aa : a){sb.append(aa);sb.append(' ');}
sb.append("\n");
}
p(sb);
}
void pl(Object... ar) {for (Object e : ar) p(e + " ");pl();}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | fb789000984fb4f347f279718b128792 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;//
public class A {
public static PrintWriter out;
public static void main(String[] args)throws IOException{
Scanner sc=new Scanner();
out=new PrintWriter(System.out);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
int pockets=b+1;
int div=r/pockets;
int remain=r%pockets;
int count=0;
String ans="";
if(b==1) {
for(int i=0;i<r/2;i++) {
ans+='R';
}
ans+='B';
for(int i=r/2;i<r;i++) {
ans+='R';
}
out.println(ans);
continue;
}
int last=div;
int l=0;
for(int i=0;i<remain;i++) {
for(int j=0;j<div+1;j++) {
ans+='R';
l++;
}
ans+='B';
l++;
}
while(l!=n-last) {
boolean ok=false;
for(int j=0;j<div;j++) {
ans+='R';
l++;
if(l==n-last) {
ok=true;
break;
}
}
if(ok) {
break;
}
ans+='B';
l++;
if(l==n-last) {
break;
}
}
for(int i=0;i<last;i++) {
ans+='R';
}
out.println(ans);
}
out.close();
}
public static class Scanner {
BufferedReader br;
StringTokenizer st;
public Scanner() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine(){
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 9a14fb76b88af2a68a2e46398605620b | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
//83 59 24
public class A {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt(), r = sc.nextInt(), b = sc.nextInt();
int range = r / (b+1);
int extra = r % (b+1);
StringBuilder ans = new StringBuilder();
int cntR = 0;
int cntB = 0;
int cnt = 0;
while (cntR < r || cntB < b) {
int start = 0;
if (cnt < extra) start = -1;
for (int i = start; i < range && cntR < r; i++) {
ans.append("R");
cntR++;
}
if (cntB < b) {
ans.append("B");
cntB++;
}
cnt++;
}
out.println(ans);
}
out.close();
}
static class Pair implements Comparable<Pair> {
int val, index;
public Pair(int x, int y) {
this.val = x;
this.index = y;
}
public int compareTo(Pair o) {
return -Integer.compare(o.val, val);
}
}
static TreeMap<Integer, Integer> dist;
static void add(int x) {
dist.put(x, dist.getOrDefault(x, 0) + 1);
}
static void remove(int x) {
dist.put(x, dist.get(x)-1);
if (dist.get(x) == 0) dist.remove(x);
}
static final Random random = new Random();
static void shuffleSort(int[] a) {
int n = a.length;
for (int i = 0; i < n; i++) {
int r = random.nextInt(n), temp = a[r];
a[r] = a[i]; a[i] = temp;
}
Arrays.sort(a);
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s){br = new BufferedReader(new InputStreamReader(s));}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {return Integer.parseInt(next());}
public long nextLong() throws IOException {return Long.parseLong(next());}
public String nextLine() throws IOException {return br.readLine();}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if(x.charAt(0) == '-') {
neg = true;
start++;
}
for(int i = start; i < x.length(); i++)
if(x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
}
else {
sb.append(x.charAt(i));
if(dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg?-1:1);
}
public boolean ready() throws IOException {return br.ready();}
int[] readArray(int n) throws IOException {
int[] a=new int[n];
for (int i=0; i<n; i++) a[i] = nextInt();
return a;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | bc9cf14fe330a2fd6362df569ed365a5 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class A {
public static void main(String[] args) throws IOException {
Reader sc = new Reader();
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
while(t-- > 0) {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
int s_grp = r / (b + 1);
int b_grp = s_grp + 1;
int n_big = r % (b + 1);
int n_small = (b + 1) - n_big;
for(int i = 0;i < n_small;i++) {
if(i != 0)
out.print("B");
for(int j = 0;j < s_grp;j++)
out.print("R");
}
for(int i = 0;i < n_big;i++) {
out.print("B");
for(int j = 0;j < b_grp;j++)
out.print("R");
}
out.println();
out.flush();
}
}
static class Reader {
BufferedReader br;
StringTokenizer st;
public Reader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
if(st.hasMoreTokens())
str = st.nextToken("\n");
else
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
}
// ********************* GCD Function *********************
//int gcd(int a, int b){
// if (b == 0)
// return a;
// return gcd(b, a % b);
//}
// ********************* Prime Number Function *********************
//int isPrime(int n){
// if(n < 2)
// return 0;
// if(n < 4)
// return 1;
// if(n % 2 == 0 or n % 3 == 0)
// return 0;
// for(int i = 5; i*i <= n; i += 6)
// if(n % i == 0 or n % (i+2) == 0)
// return 0;
// return 1;
//}
// ********************* Custom Pair Class *********************
//class Pair implements Comparable<Pair> {
// int a,b;
// public Pair(int a,int b) {
// this.a = a;
// this.b = b;
// }
// @Override
// public int compareTo(Pair other) {
// if(this.b == other.b)
// return Integer.compare(this.a,other.a);
// return Integer.compare(this.b,other.b);
// }
//}
// ****************** Segment Tree ******************
//public class SegmentTreeNode {
// public SegmentTreeNode left;
// public SegmentTreeNode right;
// public int Start;
// public int End;
// public int Sum;
// public SegmentTreeNode(int start, int end) {
// Start = start;
// End = end;
// Sum = 0;
// }
//}
//public SegmentTreeNode buildTree(int start, int end) {
// if(start > end)
// return null;
// SegmentTreeNode node = new SegmentTreeNode(start, end);
// if(start == end)
// return node;
// int mid = start + (end - start) / 2;
// node.left = buildTree(start, mid);
// node.right = buildTree(mid + 1, end);
// return node;
//}
//public void update(SegmentTreeNode node, int index) {
// if(node == null)
// return;
// if(node.Start == index && node.End == index) {
// node.Sum += 1;
// return;
// }
// int mid = node.Start + (node.End - node.Start) / 2;
// if(index <= mid)
// update(node.left, index);
// else
// update(node.right, index);
// node.Sum = node.left.Sum + node.right.Sum;
//}
//public int SumRange(SegmentTreeNode root, int start, int end) {
// if(root == null || start > end)
// return 0;
// if(root.Start == start && root.End == end)
// return root.Sum;
// int mid = root.Start + (root.End - root.Start) / 2;
// if(end <= mid)
// return SumRange(root.left, start, end);
// else if(start > mid)
// return SumRange(root.right, start, end);
// return SumRange(root.left, start, mid) + SumRange(root.right, mid + 1, end);
//} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 43888f8ea868a5db7004179d0bb488a6 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.*;
import java.lang.Math;
import java.util.StringTokenizer;
public class eleven {
public static void main(String[] args) {
int t;
char a[];
String str;
FastReader in = new FastReader();
t = in.nextInt();
while(t-- > 0) {
str = "";
String ans = "";
int x = 0;
int y = 0;
int rcount = 0;
int bcount = 0;
int n = in.nextInt();
int r = in.nextInt();
int b = in.nextInt();
a = new char[n];
x = r / (b + 1);
y = r % (b + 1);
for(int i = 0; i < x;i++) {
str += "R";
}
for(int i = 0; i < b + 1;i++) {
if(i > 0) {
ans += "B";
}
ans += str;
if(y > 0) {
ans += "R";
y--;
}
}
System.out.println(ans);
}
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
int[] readArray(int n){
int[] a = new int[n];
for(int i = 0; i < n;i++){
a[i] = nextInt();
}
return a;
}
String nextLine()
{
String str = "";
try {
if(st.hasMoreTokens()){
str = st.nextToken("\n");
}
else{
str = br.readLine();
}
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | c435c2331e45b102852dc953ef09333f | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.PrintWriter;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
in.nextLine();
while (t-- > 0) {
int n = in.nextInt();
int r = in.nextInt();
int b = in.nextInt();
int rate = rate(r, b + 1);
int consecutiveRs = 0;
in.nextLine();
StringBuilder sb = new StringBuilder();
while (n-- > 0) {
if (rate > consecutiveRs) {
sb.append('R');
consecutiveRs++;
r--;
} else if (b > 0) {
sb.append('B');
b--;
consecutiveRs = 0;
rate = rate(r, b+1);
} else if (r > 0) {
sb.append('R');
consecutiveRs++;
r--;
}
}
out.println(sb);
}
out.close();
in.close();
}
private static int rate(int r, int b) {
if (b > 0) {
return Math.round((float) r / b);
} else {
return r;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 65012efac5af935618d02d0ad715ab16 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.PrintWriter;
import java.util.Scanner;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = in.nextInt();
in.nextLine();
while (t-- > 0) {
int n = in.nextInt();
int r = in.nextInt();
int b = in.nextInt();
int rate = rate(r, b + 1);
// out.println("before r=" + r + " b=" + b + " rate=" + rate);
int consecutiveRs = 0;
in.nextLine();
StringBuilder sb = new StringBuilder();
while (n-- > 0) {
if (rate > consecutiveRs) {
sb.append('R');
consecutiveRs++;
r--;
} else if (b > 0) {
sb.append('B');
b--;
consecutiveRs = 0;
rate = rate(r, b+1);
} else if (r > 0) {
sb.append('R');
consecutiveRs++;
r--;
} else {
throw new RuntimeException("fuck up! r=" + r + " b=" + b
+ " rate " + rate + " cons " + consecutiveRs);
}
// out.println("rate " + rate + " consecutiveRs " + consecutiveRs + " r="+r + " b="+b);
}
// out.println("after r=" + r + " b=" + b);
out.println(sb);
}
out.close();
in.close();
}
private static int rate(int r, int b) {
if (b > 0) {
return Math.round((float) r / b);
} else {
return r;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 97ba27a5a4b6eabb7a73cee02d042ea6 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
new Thread(null, () -> new Main().run(), "1", 1 << 23).start();
}
private void run() {
FastReader scan = new FastReader();
PrintWriter out = new PrintWriter(System.out);
Solution solve = new Solution();
int t = scan.nextInt();
//int t = 1;
for (int qq = 0; qq < t; qq++) {
solve.solve(scan, out);
out.println();
}
out.close();
}
static class Solution {
/*
* think and coding
*/
public void solve(FastReader scan, PrintWriter out) {
int n = scan.nextInt(), r = scan.nextInt(), b = scan.nextInt();
int d = n / (b + 1);
int q = n % (b + 1);
StringBuilder ans = new StringBuilder();
for (int i = 1; i <= n; i++) {
if (i % d == 0 && b-- > 0) {
if (q-- > 0) {
ans.append("R");
}
ans.append("B");
} else {
ans.append("R");
}
if (ans.length() == n) break;
}
out.print(ans);
}
static class Point {
public int a, b;
public Point(int a, int b) {
this.a = a;
this.b = b;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Point point = (Point) o;
return a == point.a &&
b == point.b;
}
@Override
public int hashCode() {
return Objects.hash(a, b);
}
}
}
static class FastReader {
private final BufferedReader br;
private StringTokenizer st;
public FastReader() {
br = new BufferedReader(new InputStreamReader(System.in));
}
public FastReader(String s) throws FileNotFoundException {
br = new BufferedReader(new FileReader(new File(s)));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 5b32f7f3fd520d0644aa1b3210924a4f | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | // package faltu;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;
import java.util.Map.Entry;
public class Main {
public static int upperBound(long[] arr, long m, int l, int r) {
while(l<=r) {
int mid=(l+r)/2;
if(arr[mid]<=m) l=mid+1;
else r=mid-1;
}
return l;
}
public static int lowerBound(long[] a, long m, int l, int r) {
while(l<=r) {
int mid=(l+r)/2;
if(a[mid]<m) l=mid+1;
else r=mid-1;
}
return l;
}
public static long getClosest(long val1, long val2,long target)
{
if (target - val1 >= val2 - target)
return val2;
else
return val1;
}
static void ruffleSort(long[] a) {
int n=a.length;
Random r=new Random();
for (int i=0; i<a.length; i++) {
long oi=r.nextInt(n), temp=a[i];
a[i]=a[(int)oi];
a[(int)oi]=temp;
}
Arrays.sort(a);
}
static void ruffleSort(int[] a){
int n=a.length;
Random r=new Random();
for (int i=0; i<a.length; i++) {
int oi=r.nextInt(n), temp=a[i];
a[i]=a[oi];
a[oi]=temp;
}
Arrays.sort(a);
}
int ceilIndex(int input[], int T[], int end, int s){
int start = 0;
int middle;
int len = end;
while(start <= end){
middle = (start + end)/2;
if(middle < len && input[T[middle]] < s && s <= input[T[middle+1]]){
return middle+1;
}else if(input[T[middle]] < s){
start = middle+1;
}else{
end = middle-1;
}
}
return -1;
}
public static int findIndex(long arr[], long t)
{
if (arr == null) {
return -1;
}
int len = arr.length;
int i = 0;
while (i < len) {
if (arr[i] == t) {
return i;
}
else {
i = i + 1;
}
}
return -1;
}
static long gcd(long a, long b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
static int gcd(int a, int b)
{
if (a == 0)
return b;
return gcd(b % a, a);
}
static long lcm(long a,long b)
{
return (a / gcd(a, b)) * b;
}
public static int[] swap(int a[], int left, int right)
{
int temp = a[left];
a[left] = a[right];
a[right] = temp;
return a;
}
public static void swap(long x,long max1)
{
long temp=x;
x=max1;
max1=temp;
}
public static int[] reverse(int a[], int left, int right)
{
// Reverse the sub-array
while (left < right) {
int temp = a[left];
a[left++] = a[right];
a[right--] = temp;
}
return a;
}
static int lowerLimitBinarySearch(ArrayList<Integer> A,int B) {
int n =A.size();
int first = 0,second = n;
while(first <second) {
int mid = first + (second-first)/2;
if(A.get(mid) > B) {
second = mid;
}else {
first = mid+1;
}
}
if(first < n && A.get(first) < B) {
first++;
}
return first; //1 index
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
// *******----segement tree implement---*****
// -------------START--------------------------
void buildTree (int[] arr,int[] tree,int start,int end,int treeNode)
{
if(start==end)
{
tree[treeNode]=arr[start];
return;
}
buildTree(arr,tree,start,end,2*treeNode);
buildTree(arr,tree,start,end,2*treeNode+1);
tree[treeNode]=tree[treeNode*2]+tree[2*treeNode+1];
}
void updateTree(int[] arr,int[] tree,int start,int end,int treeNode,int idx,int value)
{
if(start==end)
{
arr[idx]=value;
tree[treeNode]=value;
return;
}
int mid=(start+end)/2;
if(idx>mid)
{
updateTree(arr,tree,mid+1,end,2*treeNode+1,idx,value);
}
else
{
updateTree(arr,tree,start,mid,2*treeNode,idx,value);
}
tree[treeNode]=tree[2*treeNode]+tree[2*treeNode+1];
}
// disjoint set implementation --start
static void makeSet(int n)
{
parent=new int[n];
rank=new int[n];
for(int i=0;i<n;i++)
{
parent[i]=i;
rank[i]=0;
}
}
static void union(int u,int v)
{
u=findpar(u);
v=findpar(v);
if(rank[u]<rank[v])parent[u]=v;
else if(rank[v]<rank[u])parent[v]=u;
else
{
parent[v]=u;
rank[u]++;
}
}
private static int findpar(int node)
{
if(node==parent[node])return node;
return parent[node]=findpar(parent[node]);
}
static int parent[];
static int rank[];
// *************end
static void presumbit(int[][]prebitsum) {
for(int i=1;i<=200000;i++) {
int z=i;
int j=0;
while(z>0) {
if((z&1)==1) {
prebitsum[i][j]+=(prebitsum[i-1][j]+1);
}else {
prebitsum[i][j]=prebitsum[i-1][j];
}
z=z>>1;
j++;
}
}
}
public static int[] sort(int[] arr) {
ArrayList<Integer> al = new ArrayList<>();
for(int i=0;i<arr.length;i++) al.add(arr[i]);
Collections.sort(al);
for(int i=0;i<arr.length;i++) arr[i]=al.get(i);
return arr;
}
static ArrayList<String>powof2s;
static void powof2S() {
long i=1;
while(i<(long)2e18) {
powof2s.add(String.valueOf(i));
i*=2;
}
}
static boolean coprime(int a, long l){
return (gcd(a, l) == 1);
}
static int[][] dirs = {{1,0},{-1,0},{0,1},{0,-1},{1,1},{1,-1},{-1,1},{-1,-1}};
static Long MOD=(long) (1e9+7);
static int prebitsum[][];
static ArrayList<Integer>arr;
static boolean[] vis;
static ArrayList<ArrayList<Integer>>adj;
public static void main(String[] args) throws IOException
{
// sieve();
// prebitsum=new int[200001][18];
// presumbit(prebitsum);
// powof2S();
FastReader s = new FastReader();
int tt = s.nextInt();
while(tt-->0) {
int n=s.nextInt();
int r=s.nextInt();
int b=s.nextInt();
int parts=r/(b+1);
int rem=r%(b+1);
while(r>0) {
int tot=parts;
if(rem>0) {
tot++;
rem--;
}
r-=tot;
while(tot-->0)System.out.print("R");
if(b>0) {
b--;
System.out.print("B");
}
}
System.out.println();
}
}
static void pc2d(char[][]a) {
int n=a.length;
int m=a[0].length;
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
static void pi2d(int[][]a) {
int n=a.length;
int m=a[0].length;
for(int i=0;i<n;i++) {
for(int j=0;j<m;j++) {
System.out.print(a[i][j]+" ");
}
System.out.println();
}
}
static void DFSUtil(int v, boolean[] visited)
{
visited[v] = true;
Iterator<Integer> it = adj.get(v).iterator();
while (it.hasNext()) {
int n = it.next();
if (!visited[n])
DFSUtil(n, visited);
}
}
static long DFS(int n)
{
boolean[] visited = new boolean[n+1];
long cnt=0;
for (int i = 1; i <= n; i++) {
if (!visited[i]) {
DFSUtil(i, visited);
cnt++;
}
}
return cnt;
}
public static String revStr(String str){
String input = str;
StringBuilder input1 = new StringBuilder();
input1.append(input);
input1.reverse();
return input1.toString();
}
public static String sortString(String inputString){
char tempArray[] = inputString.toCharArray();
Arrays.sort(tempArray);
return new String(tempArray);
}
static long myPow(long n, long i){
if(i==0) return 1;
if(i%2==0) return (myPow(n,i/2)%MOD * myPow(n,i/2)%MOD)%MOD;
return (n%MOD* myPow(n,i-i)%MOD)%MOD;
}
static void palindromeSubStrs(String str) {
HashSet<String>set=new HashSet<>();
char[]a =str.toCharArray();
int n=str.length();
int[][]dp=new int[n][n];
for(int g=0;g<n;g++){
for(int i=0,j=g;j<n;j++,i++){
if(!set.contains(str.substring(i,i+1))&&g==0) {
dp[i][j]=1;
set.add(str.substring(i,i+1));
}
else {
if(!set.contains(str.substring(i,j+1))&&isPalindrome(str,i,j)) {
dp[i][j]=1;
set.add(str.substring(i,j+1));
}
}
}
}
int ans=0;
for(int i=0;i<n;i++) {
for(int j=0;j<n;j++) {
System.out.print(dp[i][j]+" ");
if(dp[i][j]==1)ans++;
}
System.out.println();
}
System.out.println(ans);
}
static boolean isPalindrome(String str,int i,int j)
{
while (i < j) {
if (str.charAt(i) != str.charAt(j))
return false;
i++;
j--;
}
return true;
}
static boolean sign(long num) {
return num>0;
}
static boolean isSquare(long x){
if(x==1)return true;
long y=(long) Math.sqrt(x);
return y*y==x;
}
static long power1(long a,long b) {
if(b == 0){
return 1;
}
long ans = power(a,b/2);
ans *= ans;
if(b % 2!=0){
ans *= a;
}
return ans;
}
static void swap(StringBuilder sb,int l,int r)
{
char temp = sb.charAt(l);
sb.setCharAt(l,sb.charAt(r));
sb.setCharAt(r,temp);
}
// function to reverse the string between index l and r
static void reverse(StringBuilder sb,int l,int r)
{
while(l < r)
{
swap(sb,l,r);
l++;
r--;
}
}
// function to search a character lying between index l and r
// which is closest greater (just greater) than val
// and return it's index
static int binarySearch(StringBuilder sb,int l,int r,char val)
{
int index = -1;
while (l <= r)
{
int mid = (l+r)/2;
if (sb.charAt(mid) <= val)
{
r = mid - 1;
}
else
{
l = mid + 1;
if (index == -1 || sb.charAt(index) >= sb.charAt(mid))
index = mid;
}
}
return index;
}
// this function generates next permutation (if there exists any such permutation) from the given string
// and returns True
// Else returns false
static boolean nextPermutation(StringBuilder sb)
{
int len = sb.length();
int i = len-2;
while (i >= 0 && sb.charAt(i) >= sb.charAt(i+1))
i--;
if (i < 0)
return false;
else
{
int index = binarySearch(sb,i+1,len-1,sb.charAt(i));
swap(sb,i,index);
reverse(sb,i+1,len-1);
return true;
}
}
private static int lps(int m ,int n,String s1,String s2,int[][]mat)
{
for(int i=1;i<=m;i++)
{
for(int j=1;j<=n;j++)
{
if(s1.charAt(i-1)==s2.charAt(j-1))mat[i][j]=1+mat[i-1][j-1];
else mat[i][j]=Math.max(mat[i-1][j],mat[i][j-1]);
}
}
return mat[m][n];
}
static int lcs(String X, String Y, int m, int n)
{
int[][] L = new int[m+1][n+1];
// Following steps build L[m+1][n+1] in bottom up fashion. Note
// that L[i][j] contains length of LCS of X[0..i-1] and Y[0..j-1]
for (int i=0; i<=m; i++)
{
for (int j=0; j<=n; j++)
{
if (i == 0 || j == 0)
L[i][j] = 0;
else if (X.charAt(i-1) == Y.charAt(j-1))
L[i][j] = L[i-1][j-1] + 1;
else
L[i][j] = Math.max(L[i-1][j], L[i][j-1]);
}
}
return L[m][n];
// Following code is used to print LCS
// int index = L[m][n];
// int temp = index;
//
// // Create a character array to store the lcs string
// char[] lcs = new char[index+1];
// lcs[index] = '\u0000'; // Set the terminating character
//
// // Start from the right-most-bottom-most corner and
// // one by one store characters in lcs[]
// int i = m;
// int j = n;
// while (i > 0 && j > 0)
// {
// // If current character in X[] and Y are same, then
// // current character is part of LCS
// if (X.charAt(i-1) == Y.charAt(j-1))
// {
// // Put current character in result
// lcs[index-1] = X.charAt(i-1);
//
// // reduce values of i, j and index
// i--;
// j--;
// index--;
// }
//
// // If not same, then find the larger of two and
// // go in the direction of larger value
// else if (L[i-1][j] > L[i][j-1])
// i--;
// else
// j--;
// }
// return String.valueOf(lcs);
// Print the lcs
// System.out.print("LCS of "+X+" and "+Y+" is ");
// for(int k=0;k<=temp;k++)
// System.out.print(lcs[k]);
}
static long lis(long[] aa2, int n)
{
long lis[] = new long[n];
int i, j;
long max = 0;
for (i = 0; i < n; i++)
lis[i] = 1;
for (i = 1; i < n; i++)
for (j = 0; j < i; j++)
if (aa2[i] >= aa2[j] && lis[i] <= lis[j] + 1)
lis[i] = lis[j] + 1;
for (i = 0; i < n; i++)
if (max < lis[i])
max = lis[i];
return max;
}
static boolean isPalindrome(String str)
{
int i = 0, j = str.length() - 1;
while (i < j) {
if (str.charAt(i) != str.charAt(j))
return false;
i++;
j--;
}
return true;
}
static boolean issafe(int i, int j, int r,int c, char ch)
{
if (i < 0 || j < 0 || i >= r || j >= c|| ch!= '1')return false;
else return true;
}
static long power(long a, long b)
{
a %=MOD;
long out = 1;
while (b > 0) {
if((b&1)!=0)out = out * a % MOD;
a = a * a % MOD;
b >>= 1;
a*=a;
}
return out;
}
static long[] sieve;
public static void sieve()
{
int nnn=(int) 1e6+1;
long nn=(int) 1e6;
sieve=new long[(int) nnn];
int[] freq=new int[(int) nnn];
sieve[0]=0;
sieve[1]=1;
for(int i=2;i<=nn;i++)
{
sieve[i]=1;
freq[i]=1;
}
for(int i=2;i*i<=nn;i++)
{
if(sieve[i]==1)
{
for(int j=i*i;j<=nn;j+=i)
{
if(sieve[j]==1)
{
sieve[j]=0;
}
}
}
}
}
}
class decrease implements Comparator<Long> {
// Used for sorting in ascending order of
// roll number
public int compare(long a, long b)
{
return (int) (b - a);
}
@Override
public int compare(Long o1, Long o2) {
// TODO Auto-generated method stub
return (int) (o2-o1);
}
}
class pair{
long x;
long y;
long c;
char ch;
public pair(long x,long y) {
this.x=x;
this.y=y;
}
public pair(long x,char ch) {
this.x=x;
this.ch=ch;
}
public pair(long x,long y,long c)
{
this.x=x;
this.y=y;
this.c=c;
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 3aa9bf0f184ef83f20fa45839743e687 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes |
import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;
public class Practice1 {
// static long[] sort(long[] arr) {
// int n=arr.length;
// ArrayList<Long> al=new ArrayList<>();
// for(int i=0;i<n;i++) {
// al.add(arr[i]);
// }
// Collections.sort(al);
// for(int i=0;i<n;i++) {
// arr[i]=al.get(i);
// }
// return arr;
// }
//
// static long nCr(int n, int r)
// {
// // int x=1000000007;
// long dp[][]=new long[2][r+1];
//
// for(int i=0;i<=n;i++){
// for(int j=0;j<=i&&j<=r;j++){
// if(i==0||j==0||i==j){
// dp[i%2][j]=1;
// }else {
//
// // dp[i%2][j]=(dp[(i-1)%2][j]+dp[(i-1)%2][j-1])%x;
// dp[i%2][j]=(dp[(i-1)%2][j]+dp[(i-1)%2][j-1]);
// }
//
// }
// }
//
// return dp[n%2][r];
//
// }
//
public static class UnionFind {
private final int[] p;
public UnionFind(int n) {
p = new int[n];
for (int i = 0; i < n; i++) {
p[i] = i;
}
}
public int find(int x) {
return x == p[x] ? x : (p[x] = find(p[x]));
}
public void union(int x, int y) {
x = find(x);
y = find(y);
if (x != y) {
p[x] = y;
}
}
}
public static boolean ispalin(String str) {
int n=str.length();
for(int i=0;i<n/2;i++) {
if(str.charAt(i)!=str.charAt(n-i-1)) {
return false;
}
}
return true;
}
static long power(long N,long R)
{
long x=1000000007;
if(R==0) return 1;
if(R==1) return N;
long temp= power(N,R/2)%x; // (a*b)%p = (a%p*b%p)*p
temp=(temp*temp)%x;
if(R%2==0){
return temp%x;
}else{
return (N*temp)%x;
}
}
public static String binary(int n) {
StringBuffer ans=new StringBuffer();
int a=4;
while(a-->0) {
int temp=(n&1);
if(temp!=0) {
ans.append('1');
}else {
ans.append('0');
}
n =n>>1;
}
ans=ans.reverse();
return ans.toString();
}
public static int find(String[][] arr,boolean[][] vis,int dir,int i,int j) {
if(i<0||i>=arr.length||j<0||j>=arr[0].length) return 0;
if(vis[i][j]==true) return 0;
if(dir==1&&arr[i][j].charAt(0)=='1') return 0;
if(dir==2&&arr[i][j].charAt(1)=='1') return 0;
if(dir==3&&arr[i][j].charAt(2)=='1') return 0;
if(dir==4&&arr[i][j].charAt(3)=='1') return 0;
vis[i][j]=true;
int a=find(arr,vis,1,i+1,j);
int b=find(arr,vis,2,i-1,j);
int c=find(arr,vis,3,i,j+1);
int d=find(arr,vis,4,i,j-1);
return 1+a+b+c+d;
}
// static ArrayList<Integer> allDivisors(int n) {
// ArrayList<Integer> al=new ArrayList<>();
// int i=2;
// while(i*i<=n) {
// if(n%i==0) al.add(i);
// if(n%i==0&&i*i!=n) al.add(n/i);
// i++;
// }
// return al;
// }
// static int[] sort(int[] arr) {
// int n=arr.length;
// ArrayList<Integer> al=new ArrayList<>();
// for(int i=0;i<n;i++) {
// al.add(arr[i]);
// }
// Collections.sort(al);
// for(int i=0;i<n;i++) {
// arr[i]=al.get(i);
// }
// return arr;
// }
//
/** Code for Dijkstra's algorithm **/
public static class ListNode {
int vertex, weight;
ListNode(int v, int w) {
vertex = v;
weight = w;
}
int getVertex() { return vertex; }
int getWeight() { return weight; }
}
public static int[] dijkstra(
int V, ArrayList<ArrayList<ListNode> > graph,
int source) {
int[] distance = new int[V];
for (int i = 0; i < V; i++)
distance[i] = Integer.MAX_VALUE;
distance[0] = 0;
PriorityQueue<ListNode> pq = new PriorityQueue<>(
(v1, v2) -> v1.getWeight() - v2.getWeight());
pq.add(new ListNode(source, 0));
while (pq.size() > 0) {
ListNode current = pq.poll();
for (ListNode n :
graph.get(current.getVertex())) {
if (distance[current.getVertex()]
+ n.getWeight()
< distance[n.getVertex()]) {
distance[n.getVertex()]
= n.getWeight()
+ distance[current.getVertex()];
pq.add(new ListNode(
n.getVertex(),
distance[n.getVertex()]));
}
}
}
// If you want to calculate distance from source to
// a particular target, you can return
// distance[target]
return distance;
}
static long gcd(long a, long b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
static class Pair{
int l;
int r;
char c;
Pair(int l,int r,char c){
this.l=l;
this.r=r;
this.c=c;
}
}
public static void fill(int[][] arr,boolean[][] vis, int i,int j,int k,int l) {
int n=arr.length;
int m=arr[0].length;
if(i<0||j<0||i>=n||j>=m||vis[i][j]==true) return;
vis[i][j]=true;
int max=0;
if(i+1<n) {
max=Math.max(arr[i+1][j],max);
}
if(i-1>=0) {
max=Math.max(arr[i-1][j],max);
}
if(j+1<m) {
max=Math.max(arr[i][j+1],max);
}
if(j-1>=0) {
max=Math.max(arr[i][j-1],max);
}
arr[i][j]=Math.min(l-max,k);
fill(arr,vis,i+1,j,k,l);
fill(arr,vis,i-1,j,k,l);
fill(arr,vis,i,j+1,k,l);
fill(arr,vis,i,j-1,k,l);
}
static long nCr(int n, int r)
{
// int x=1000000007;
long dp[][]=new long[2][r+1];
for(int i=0;i<=n;i++){
for(int j=0;j<=i&&j<=r;j++){
if(i==0||j==0||i==j){
dp[i%2][j]=1;
}else {
// dp[i%2][j]=(dp[(i-1)%2][j]+dp[(i-1)%2][j-1])%x;
dp[i%2][j]=(dp[(i-1)%2][j]+dp[(i-1)%2][j-1]);
}
}
}
return dp[n%2][r];
}
static int[] sort(int[] arr) {
int n=arr.length;
ArrayList<Integer> al=new ArrayList<>();
for(int i=0;i<n;i++) {
al.add(arr[i]);
}
Collections.sort(al);
for(int i=0;i<n;i++) {
arr[i]=al.get(i);
}
return arr;
}
static boolean isPrime(int n)
{
if (n <= 1)
return false;
else if (n == 2)
return true;
else if (n % 2 == 0)
return false;
for (int i = 3; i <= Math.sqrt(n); i += 2)
{
if (n % i == 0)
return false;
}
return true;
}
public static void main (String[] args) {
PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
// out.print();
//out.println();
FastReader sc=new FastReader();
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
int div=r/(b+1);
int rem=r%(b+1);
StringBuffer ans=new StringBuffer();
for(int i=0;i<b+1;i++) {
int a=div;
if(rem>0) a++;
rem--;
//out.println("div : "+div);
//out.println("a : "+a);
while(a>0) {
ans.append("R");
a--;
}
if(i!=(b+1)-1)ans.append("B");
}
out.println(ans);
}
out.close();
}
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader()
{
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next()
{
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
}
catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() { return Integer.parseInt(next()); }
long nextLong() { return Long.parseLong(next()); }
double nextDouble()
{
return Double.parseDouble(next());
}
String nextLine()
{
String str = "";
try {
str = br.readLine();
}
catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 8f803bf3694c456917fcc0a36315dd07 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class Main {
static void solve() {
Scanner scan = new Scanner(System.in);
int t = scan.nextInt();
for (int i = 0; i < t; i++) {
int n = scan.nextInt();
int r = scan.nextInt();
int b = scan.nextInt();
solveCase(n, r, b);
}
}
static void solveCase(int n, int r, int b) {
int diff = r - b - 1;
int addToAll = diff/(b+1);
int addOneMore = diff%(b+1);
StringBuilder sb = new StringBuilder();
int cnt = addToAll;
while(cnt > 0 && r > 0) {
sb.append('R');
r--;
cnt--;
}
if(addOneMore > 0 && r > 0) {
sb.append('R');
r--;
addOneMore--;
}
sb.append("R");
r--;
while(b > 0 && r > 0) {
sb.append("BR");
r--; b--;
cnt = addToAll;
if(addOneMore > 0 && r > 0) {
sb.append("R");
addOneMore--;
r--;
}
while (cnt > 0 && r > 0) {
sb.append("R");
cnt--; r--;
}
}
while(b > 0) {
sb.append("B");
b--;
}
while(r > 0) {
sb.append("R");
r--;
}
System.out.println(sb.toString());
}
public static void main(String[] args) {
solve();
}
static class Node implements Comparable<Node> {
long val;
Node parent;
List<Node> children;
long max;
boolean isLeave;
public Node(int val) {
this.val = val;
this.max = val;
isLeave = true;
children = new ArrayList<>();
}
@Override
public int compareTo(Node node) {
if(this.max < node.max) {
return -1;
} else if(this.max > node.max) {
return 1;
}
return 0;
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | e939ab4406b248b9d3c0c49361f83b4a | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
public class BestMatches {
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for (int i=0;i<t;i++) {
int n = sc.nextInt();
int r = sc.nextInt();
int b = sc.nextInt();
StringBuffer res = new StringBuffer();
int every=r/(b+1);
int rest=r%(b+1);
while (b>0){
for (int j=0;j<every&&r>0;j++){
res.append('R');
r--;
}
if(rest>0){
res.append('R');
rest--;
r--;
}
res.append('B');
b--;
}
while (r>0){
res.append('R');
r--;
}
System.out.println(res);
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | c44b383e6e0824216000fa5ca6617532 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import static java.lang.System.out;
import static java.lang.Math.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
Read in = new Read(System.in);
int tN = in.nextInt();
while(tN > 0) {
tN--;
int n=in.nextInt();
long r = in.nextInt();
long b = in.nextInt();
int cot = 1;
while(true) {
if(cot*b >= r - cot) {
break;
}
cot++;
}
r = r - (b + 1);
for(int i = 0;i<=b;i++) {
out.print('R');
for(int j = 0;j<cot - 1 && r>0;j++) {
r--;
out.print('R');
}
if(i!=b)
out.print('B');
}
out.println();
}
}
static class Read {//自定义快读 Read
public BufferedReader reader;
public StringTokenizer tokenizer;
public Read(InputStream stream) {
reader = new BufferedReader(new InputStreamReader(stream), 32768);
tokenizer = null;
}
public String next() {
while (tokenizer == null || !tokenizer.hasMoreTokens()) {
try {
tokenizer = new StringTokenizer(reader.readLine());
} catch (IOException e) {
throw new RuntimeException(e);
}
}
return tokenizer.nextToken();
}
public String nextLine() {
String str = null;
try {
str = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
public int nextInt() {
return Integer.parseInt(next());
}
public long nextLong() {
return Long.parseLong(next());
}
public Double nextDouble() {
return Double.parseDouble(next());
}
public BigInteger nextBigInteger() {
return new BigInteger(next());
}
}
static long lcm(long a, long b) {
return (a * b) / gcd(a, b);
}
static long gcd(long a, long b) {
return (a % b == 0) ? b : gcd(b, a % b);
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | d5faca73538e2586dced1eba83e35e0d | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.util.*;
import static java.lang.System.out;
import static java.lang.Math.*;
public class pre388 {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(
new InputStreamReader(System.in));
}
String next() {
while (st == null || !st.hasMoreElements()) {
try {
st = new StringTokenizer(br.readLine());
} catch (IOException e) {
e.printStackTrace();
}
}
return st.nextToken();
}
int nextInt() {
return Integer.parseInt(next());
}
long nextLong() {
return Long.parseLong(next());
}
double nextDouble() {
return Double.parseDouble(next());
}
String nextLine() {
String str = "";
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
static class MultiSet<K> {
TreeMap<K, Integer> map;
MultiSet() {
map = new TreeMap<>();
}
void add(K a) {
map.put(a, map.getOrDefault(a, 0) + 1);
}
boolean contains(K a) {
return map.containsKey(a);
}
void remove(K a) {
map.put(a, map.get(a) - 1);
if (map.get(a) == 0) map.remove(a);
}
int occrence(K a) {
return map.get(a);
}
K floor(K a) {
return map.floorKey(a);
}
K ceil(K a) {
return map.ceilingKey(a);
}
@Override
public String toString() {
ArrayList<K> set = new ArrayList<>();
for (Map.Entry<K, Integer> i : map.entrySet()) {
for (int j = 1; j <= i.getValue(); j++) set.add(i.getKey());
}
return set.toString();
}
}
static class Pair<K, V> {
K value1;
V value2;
Pair(K a, V b) {
value1 = a;
value2 = b;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Pair)) return false;
Pair<?, ?> p = (Pair<?, ?>) o;
return Objects.equals(this.value1, p.value1) && Objects.equals(this.value2, p.value2);
}
@Override
public int hashCode() {
int result = this.value1.hashCode();
result = 31 * result + this.value2.hashCode();
return result;
}
@Override
public String toString() {
return ("[" + value1 + " <=> " + value2 + "]");
}
}
static ArrayList<Integer> primes;
static void setPrimes(int n) {
boolean p[] = new boolean[n];
Arrays.fill(p, true);
for (int i = 2; i < p.length; i++) {
if (p[i]) {
primes.add(i);
for (int j = i * 2; j < p.length; j += i) p[j] = false;
}
}
}
static int mod = (int) (1e9 + 7);
static int gcd(int a, int b) {
if (a == 0) return b;
return gcd(b % a, a);
}
public static void main(String args[]) {
FastReader obj = new FastReader();
int tc = obj.nextInt();
while(tc--!=0){
int n = obj.nextInt(),r = obj.nextInt(),b = obj.nextInt();
int ans[] = new int[b+1],top = 0;
while(r>0){
ans[top%(b+1)]++;
r--;
top++;
}
for(int i=0;i<b;i++){
for(int j=0;j<ans[i];j++) out.print('R');
out.print('B');
}
for(int i=0;i<ans[b];i++) out.print('R');
out.println();
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 8d989f75c9e9485df7bcdbec211c4b81 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
public static long gcd(long a, long b) {
return a == 0 ? b : gcd(b, a % b);
}
public static void print(int[] a) {
PrintWriter out = new PrintWriter(System.out);
for (int i = 0; i < a.length; i++) {
out.print(a[i] + " ");
}
out.println();
out.close();
}
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t1 = sc.nextInt();
while (t1-- > 0) {
boolean g = false;
int n = sc.nextInt(), r = sc.nextInt(), b = sc.nextInt();
int q = r % (b + 1);
int h = r / (b + 1);
while (r > 0 || b > 0) {
for (int i = 0; i < h && r > 0; i++) {
out.print("R");
r--;
if (i == h - 1 && q > 0) {
out.print("R");
r--;
q--;
}
}
if (b > 0) {
out.print("B");
b--;
}
}
out.println();
}
out.close();
}
static class Pair implements Comparable<Pair> {
int first;
int second;
public Pair(int first, int second) {
this.first = first;
this.second = second;
}
public int compareTo(Pair p) {
if (first != p.first)
return Integer.compare(first, p.first);
else if (second != p.second)
return Integer.compare(second, p.second);
else
return 0;
}
}
static final Random random = new Random();
static void shuffleSort(int[] a) {
int n = a.length;
for (int i = 0; i < n; i++) {
int r = random.nextInt(n), temp = a[r];
a[r] = a[i];
a[i] = temp;
}
Arrays.sort(a);
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public boolean ready() throws IOException {
return br.ready();
}
int[] readArray(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | c484bc8baae90da6e420109f3560a0cb | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
public static long gcd(long a, long b) {
return a == 0 ? b : gcd(b, a % b);
}
public static void print(int[] a) {
PrintWriter out = new PrintWriter(System.out);
for (int i = 0; i < a.length; i++) {
out.print(a[i] + " ");
}
out.println();
out.close();
}
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t1 = sc.nextInt();
while (t1-->0) {
boolean g = false;
int n = sc.nextInt(), r = sc.nextInt(),b = sc.nextInt();
if (b == 1) {
for (int i = 0;i<r;i++) {
out.print("R");
if (i == n/2-1) {
out.print("B");
}
}
}else {
int q = r%(b+1);
int h = r/(b+1);
while(r>0 || b>0) {
for (int i =0;i<h && r>0;i++) {
out.print("R");
r--;
if (i == h-1 && q>0 ) {
out.print("R");
r--;
q--;
}
}
if (b>0) {
out.print("B");
b--;
}
}
}
out.println();
}
out.close();
}
static class Pair implements Comparable<Pair> {
int first;
int second;
public Pair(int first, int second) {
this.first = first;
this.second = second;
}
public int compareTo(Pair p) {
if (first != p.first)
return Integer.compare(first, p.first);
else if (second != p.second)
return Integer.compare(second, p.second);
else
return 0;
}
}
static final Random random = new Random();
static void shuffleSort(int[] a) {
int n = a.length;
for (int i = 0; i < n; i++) {
int r = random.nextInt(n), temp = a[r];
a[r] = a[i];
a[i] = temp;
}
Arrays.sort(a);
}
static class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public boolean ready() throws IOException {
return br.ready();
}
int[] readArray(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | af4dca35fe72bd7c9c897ca532aff6e0 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
public class temp{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0){
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
while(b>0 || r>0){
int maxWin=r%(b+1)==0?r/(b+1):r/(b+1)+1;
int j=1;
while(j<=r && j<=maxWin){
System.out.print("R");
r--;
j++;
}
if(b>0){
System.out.print("B");
b--;
}
}
System.out.println();
t--;
}
sc.close();
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | b9a4af2d4705ff8793b5c21e81788334 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
public class pro{
public static void main(String[]args){
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
String ans="";
while(b>0)
{
int max=(int)Math.ceil((float)r/(b+1));
for(int i=0;i<max;i++){
ans+='R';
}
ans+='B';
b-=1;
r-=max;
}
for(int i=0;i<r;i++){
ans+='R';
}
System.out.println(ans);
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | a0a3cfb32525dca0b04c95f81f111f02 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static class Pair implements Comparable < Pair > {
int d;
int i;
Pair(int d, int i) {
this.d = d;
this.i = i;
}
public int compareTo(Pair o) {
if (this.d == o.d)
return this.i - o.i;
if (this.d < o.d)
return -1;
else
return 1;
}
}
public static class SegmentTree {
long[] st;
long[] lazy;
int n;
SegmentTree(long[] arr, int n) {
this.n = n;
st = new long[4 * n];
lazy = new long[4 * n];
construct(arr, 0, n - 1, 0);
}
public long construct(long[] arr, int si, int ei, int node) {
if (si == ei) {
st[node] = arr[si];
return arr[si];
}
int mid = (si + ei) / 2;
long left = construct(arr, si, mid, 2 * node + 1);
long right = construct(arr, mid + 1, ei, 2 * node + 2);
st[node] = left + right;
return st[node];
}
public long get(int l, int r) {
return get(0, n - 1, l, r, 0);
}
public long get(int si, int ei, int l, int r, int node) {
if (r < si || l > ei)
return 0;
if (lazy[node] != 0) {
st[node] += lazy[node] * (ei - si + 1);
if (si != ei) {
lazy[2 * node + 1] += lazy[node];
lazy[2 * node + 2] += lazy[node];
}
lazy[node] = 0;
}
if (l <= si && r >= ei)
return st[node];
int mid = (si + ei) / 2;
return get(si, mid, l, r, 2 * node + 1) + get(mid + 1, ei, l, r, 2 * node + 2);
}
public void update(int index, int value) {
update(0, n - 1, index, 0, value);
}
public void update(int si, int ei, int index, int node, int val) {
if (si == ei) {
st[node] = val;
return;
}
int mid = (si + ei) / 2;
if (index <= mid) {
update(si, mid, index, 2 * node + 1, val);
} else {
update(mid + 1, ei, index, 2 * node + 2, val);
}
st[node] = st[2 * node + 1] + st[2 * node + 2];
}
public void rangeUpdate(int l, int r, int val) {
rangeUpdate(0, n - 1, l, r, 0, val);
}
public void rangeUpdate(int si, int ei, int l, int r, int node, int val) {
if (r < si || l > ei)
return;
if (lazy[node] != 0) {
st[node] += lazy[node] * (ei - si + 1);
if (si != ei) {
lazy[2 * node + 1] += lazy[node];
lazy[2 * node + 2] += lazy[node];
}
lazy[node] = 0;
}
if (l <= si && r >= ei) {
st[node] += val * (ei - si + 1);
if (si != ei) {
lazy[2 * node + 1] += val;
lazy[2 * node + 2] += val;
}
return;
}
int mid = (si + ei) / 2;
rangeUpdate(si, mid, l, r, 2 * node + 1, val);
rangeUpdate(mid + 1, ei, l, r, 2 * node + 2, val);
st[node] = st[2 * node + 1] + st[2 * node + 2];
}
}
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead;
public Reader() {
din = new DataInputStream(System.in);
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public Reader(String file_name) throws IOException {
din = new DataInputStream(
new FileInputStream(file_name));
buffer = new byte[BUFFER_SIZE];
bufferPointer = bytesRead = 0;
}
public String readLine() throws IOException {
byte[] buf = new byte[64]; // line length
int cnt = 0, c;
while ((c = read()) != -1) {
if (c == '\n') {
if (cnt != 0) {
break;
} else {
continue;
}
}
buf[cnt++] = (byte)c;
}
return new String(buf, 0, cnt);
}
public int nextInt() throws IOException {
int ret = 0;
byte c = read();
while (c <= ' ') {
c = read();
}
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public long nextLong() throws IOException {
long ret = 0;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (neg)
return -ret;
return ret;
}
public double nextDouble() throws IOException {
double ret = 0, div = 1;
byte c = read();
while (c <= ' ')
c = read();
boolean neg = (c == '-');
if (neg)
c = read();
do {
ret = ret * 10 + c - '0';
} while ((c = read()) >= '0' && c <= '9');
if (c == '.') {
while ((c = read()) >= '0' && c <= '9') {
ret += (c - '0') / (div *= 10);
}
}
if (neg)
return -ret;
return ret;
}
private void fillBuffer() throws IOException {
bytesRead = din.read(buffer, bufferPointer = 0,
BUFFER_SIZE);
if (bytesRead == -1)
buffer[0] = -1;
}
private byte read() throws IOException {
if (bufferPointer == bytesRead)
fillBuffer();
return buffer[bufferPointer++];
}
public void close() throws IOException {
if (din == null)
return;
din.close();
}
}
public static void main(String[] args) throws IOException {
if (System.getProperty("ONLINE_JUDGE") == null) {
try {
System.setIn(new FileInputStream(new File("input.txt")));
System.setOut(new PrintStream(new File("output.txt")));
} catch (Exception e) {
}
}
Reader sc = new Reader();
int tc = sc.nextInt();
StringBuilder sb = new StringBuilder();
while (tc-- > 0) {
int n = sc.nextInt();
int a = sc.nextInt();
int b = sc.nextInt();
int k = (a / (b + 1));
int r = ((a) % (b + 1));
for (int i = 0; i < r; i++) {
for (int j = 0; j <= k; j++)
sb.append('R');
sb.append('B');
}
for (int i = r ; i < b; i++) {
for (int j = 0; j < k; j++)
sb.append('R');
sb.append('B');
}
for (int i = 0; i < k; i++)
sb.append('R');
sb.append("\n");
}
System.out.println(sb);
}
public static void DFS(ArrayList<ArrayList<Integer>> graph, boolean[] vis, int node) {
vis[node] = true;
for (int x : graph.get(node)) {
if (!vis[x])
DFS(graph, vis, x);
}
}
public static int log2(long N) {
// calculate log2 N indirectly
// using log() method
int result = (int)Math.ceil((Math.log(N) / Math.log(2)));
return result;
}
static long power(long x, long y, long p) {
long res = 1; // Initialize result
// Update x if it is more
// than or equal to p
x = x % p;
while (y > 0) {
// If y is odd, multiply
// x with the result
if ((y & 1) > 0)
res = (res * x) % p;
// y must be even now
y = y >> 1; // y = y/2
x = (x * x) % p;
}
return res;
}
public static int countBit(long n) {
int count = 0;
while (n > 0) {
count += (n & 1);
n /= 2;
}
return count;
}
public static int get(int[] dsu, int x) {
if (dsu[x] == x)
return x;
int k = get(dsu, dsu[x]);
dsu[x] = k;
return k;
}
static int gcd(int a, int b) {
// Everything divides 0
if (a == 0)
return b;
if (b == 0)
return a;
// base case
if (a == b)
return a;
// a is greater
if (a > b)
return gcd(a - b, b);
return gcd(a, b - a);
}
public static int Xor(int n) {
if (n % 4 == 0)
return n;
// If n%4 gives remainder 1
if (n % 4 == 1)
return 1;
// If n%4 gives remainder 2
if (n % 4 == 2)
return n + 1;
// If n%4 gives remainder 3
return 0;
}
public static long pow(long a, long b, long mod) {
long res = 1;
while (b > 0) {
if ((b & 1) > 0)
res = (res * a) % mod;
b = b >> 1;
a = ((a % mod) * (a % mod)) % mod;
}
return (res % mod + mod) % mod;
}
public static double digit(long num) {
return Math.floor(Math.log10(num) + 1);
}
static int upperBound(ArrayList<Long> arr, long key) {
int mid, N = arr.size();
// Initialise starting index and
// ending index
int low = 0;
int high = N;
// Till low is less than high
while (low < high && low != N) {
// Find the index of the middle element
mid = low + (high - low) / 2;
// If key is greater than or equal
// to arr[mid], then find in
// right subarray
if (key >= arr.get(mid)) {
low = mid + 1;
}
// If key is less than arr[mid]
// then find in left subarray
else {
high = mid;
}
}
// If key is greater than last element which is
// array[n-1] then upper bound
// does not exists in the array
return low;
}
static int lowerBound(ArrayList<Long> array, long key) {
// Initialize starting index and
// ending index
int low = 0, high = array.size();
int mid;
// Till high does not crosses low
while (low < high) {
// Find the index of the middle element
mid = low + (high - low) / 2;
// If key is less than or equal
// to array[mid], then find in
// left subarray
if (key <= array.get(mid)) {
high = mid;
}
// If key is greater than array[mid],
// then find in right subarray
else {
low = mid + 1;
}
}
// If key is greater than last element which is
// array[n-1] then lower bound
// does not exists in the array
if (low < array.size() && array.get(low) < key) {
low++;
}
// Returning the lower_bound index
return low;
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 210c09454474dd18c0613bfb854cca6f | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | //import java.io.IOException;
import java.io.*;
import java.util.*;
public class RedVersusBlue {
static InputReader inputReader=new InputReader(System.in);
static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
static void solve() throws IOException {
int n = inputReader.nextInt();
int a = inputReader.nextInt();
int b = inputReader.nextInt();
char[] s = new char[n];
for (int i = 0; i < n; ) {
int g = (a + b) / (b + 1);
for (int j = 0; j < g && a > 0; j++) {
s[i++] = 'R';
a--;
}
if (b > 0) {
s[i++] = 'B';
b--;
}
}
out.println(new String(s));
}
static PrintWriter out=new PrintWriter((System.out));
static void SortDec(long arr[])
{
List<Long>list=new ArrayList<>();
for(long ele:arr) {
list.add(ele);
}
Collections.sort(list,Collections.reverseOrder());
for (int i=0;i<list.size();i++)
{
arr[i]=list.get(i);
}
}
static void Sort(long arr[])
{
List<Long>list=new ArrayList<>();
for(long ele:arr) {
list.add(ele);
}
Collections.sort(list);
for (int i=0;i<list.size();i++)
{
arr[i]=list.get(i);
}
}
public static void main(String args[])throws IOException
{
int t=inputReader.nextInt();
while (t-->0) {
solve();
}
long s = System.currentTimeMillis();
// out.println(System.currentTimeMillis()-s+"ms");
out.close();
}
static class InputReader {
private InputStream stream;
private byte[] buf = new byte[8192];
private int curChar, snumChars;
private SpaceCharFilter filter;
public InputReader(InputStream stream) {
this.stream = stream;
}
public int snext() {
if (snumChars == -1)
throw new InputMismatchException();
if (curChar >= snumChars) {
curChar = 0;
try {
snumChars = stream.read(buf);
} catch (IOException e) {
throw new InputMismatchException();
}
if (snumChars <= 0)
return -1;
}
return buf[curChar++];
}
public int nextInt() {
int c = snext();
while (isSpaceChar(c))
c = snext();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = snext();
}
int res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = snext();
} while (!isSpaceChar(c));
return res * sgn;
}
public long nextLong() {
int c = snext();
while (isSpaceChar(c))
c = snext();
int sgn = 1;
if (c == '-') {
sgn = -1;
c = snext();
}
long res = 0;
do {
if (c < '0' || c > '9')
throw new InputMismatchException();
res *= 10;
res += c - '0';
c = snext();
} while (!isSpaceChar(c));
return res * sgn;
}
public int[] nextIntArray(int n) {
int a[] = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public String readString() {
int c = snext();
while (isSpaceChar(c))
c = snext();
StringBuilder res = new StringBuilder();
do {
res.appendCodePoint(c);
c = snext();
} while (!isSpaceChar(c));
return res.toString();
}
public boolean isSpaceChar(int c) {
if (filter != null)
return filter.isSpaceChar(c);
return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
}
public interface SpaceCharFilter {
public boolean isSpaceChar(int ch);
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 055b7b65ce14c48a64d8053a9729d592 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.StringTokenizer;
public class maina {
static Scanner sc = new Scanner(System.in);
// static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter pw = new PrintWriter(System.out);
public static void main(String args[]) throws IOException, Exception {
int t = sc.nextInt();
while (t-- > 0) {
int n = sc.nextInt(), r = sc.nextInt(), b = sc.nextInt();
char fi = Math.max(r, b) == r ? 'R' : 'B';
char sec = 'R';
if (fi == 'R')
sec = 'B';
int len = Math.max(r, b) / (Math.min(r, b) + 1);
int mod = Math.max(r, b) % (Math.min(r, b) + 1);
if (mod != 0) {
int max = (Math.min(r, b) + 1) * (len + 1);
len = max / (Math.min(r, b) + 1);
}
if (b * len + b > n)
len = Math.max(r, b) / (Math.min(r, b) + 1);
int bb = r - len * b;
int c = 0;
if (bb <= len)
bb = 0;
for (int i = 0; i < Math.min(r, b); i++) {
int j = bb-- > 0 ? -1 : 0;
for (; j < len; j++, c++) {
pw.print(fi);
}
pw.print(sec);
c++;
}
for (; c < n; c++)
pw.print(fi);
pw.println();
}
pw.close();
}
/*
* static int[][] pa = new int[3][4]; static Boolean[][] memo1 = new Boolean[4 +
* 1][(int) 1e7];
*
* static boolean paint(int i, int sum_till) { if (i == 4) return sum_till ==
* (int) 1e6; if (memo1[i][sum_till] != null) return memo1[i][sum_till]; if
* (sum_till > (int) 1e6) return false;
*
* return memo1[i][sum_till] = paint(i + 1, sum_till) || paint(i + 1, sum_till +
* pa[0][i]) || paint(i + 1, sum_till + pa[1][i]) || paint(i + 1, sum_till +
* pa[2][i]);
*
* }
*
* static void draw_row(int s, int c) { char r1[] = { '.', '|' }; char r2[] = {
* '+', '-' }; int s1 = 0; for (int j = 0; j < 2; j++) {
*
* for (int i = 0; i < c * 2 + 1; i++) {
*
* if (j == 0) {
*
* if (s == 3) { pw.print(".."); i++; s = 0; } else pw.print(r1[s]);
*
* } else pw.print(r2[s]);
*
* if (s != 3) s = (s + 1) % 2;
*
* } pw.println();
*
* }
*
* }
*
* static int count_bits(int bit_num, int x) { int b = (int) Math.pow(2, bit_num
* - 1);
*
* int y = ((int) (x / (2 * b))) * b; int rem = x % (b * 2); if (rem == 0) y +=
* rem; else y += (rem / b); return y; }
*
* private static int count(ArrayList<Boolean> x, int len, int i) { int c = 0;
* while (len-- > 0) { if (x.get(i++)) c++; } return c; }
*
* static long mod = 998244353;
*
* /* static void bb() throws IOException { int t = sc.nextInt(); while (t-- >
* 0) { int n = sc.nextInt(); if (n % 2 == 1) pw.println(0); else { long x =
* fact((int) (0.5 * n)); pw.println(((x % mod) * (x % mod)) % mod); //
* pw.println((x * x) % mod);
*
* }
*
* }
*
* }
*
* static Long memo[] = new Long[(int) 1e3 + 1];
*/
}
//////////////////////////////////////////
class Scanner {
StringTokenizer st;
BufferedReader br;
public Scanner(InputStream s) {
br = new BufferedReader(new InputStreamReader(s));
}
public Scanner(FileReader r) {
br = new BufferedReader(r);
}
public String next() throws IOException {
while (st == null || !st.hasMoreTokens())
st = new StringTokenizer(br.readLine());
return st.nextToken();
}
public int nextInt() throws IOException {
return Integer.parseInt(next());
}
public long nextLong() throws IOException {
return Long.parseLong(next());
}
public String nextLine() throws IOException {
return br.readLine();
}
public double nextDouble() throws IOException {
String x = next();
StringBuilder sb = new StringBuilder("0");
double res = 0, f = 1;
boolean dec = false, neg = false;
int start = 0;
if (x.charAt(0) == '-') {
neg = true;
start++;
}
for (int i = start; i < x.length(); i++)
if (x.charAt(i) == '.') {
res = Long.parseLong(sb.toString());
sb = new StringBuilder("0");
dec = true;
} else {
sb.append(x.charAt(i));
if (dec)
f *= 10;
}
res += Long.parseLong(sb.toString()) / f;
return res * (neg ? -1 : 1);
}
public long[] nextlongArray(int n) throws IOException {
long[] a = new long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public Long[] nextLongArray(int n) throws IOException {
Long[] a = new Long[n];
for (int i = 0; i < n; i++)
a[i] = nextLong();
return a;
}
public int[] nextIntArray(int n) throws IOException {
int[] a = new int[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public byte[] nextByteArray(int n) throws IOException {
byte[] a = new byte[n];
for (int i = 0; i < n; i++)
a[i] = (byte) nextInt();
return a;
}
public Integer[] nextIntegerArray(int n) throws IOException {
Integer[] a = new Integer[n];
for (int i = 0; i < n; i++)
a[i] = nextInt();
return a;
}
public boolean ready() throws IOException {
return br.ready();
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | b89b262445623ae86ca6cc054af1e7ba | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
public class Contest_yandexA{
//static final int MAXN = (int)1e6;
public static void main(String[] args) throws IOException{
Scanner input = new Scanner(System.in);
int t = input.nextInt();
for(int tt = 0;tt<t;tt++){
int n = input.nextInt();
int r = input.nextInt();
int b = input.nextInt();
int x = r/(b+1);
int mod = r%(b+1);
String red = "";
for(int i = 0;i<x;i++){
red+= "R";
}
for(int i = 0;i<b;i++){
System.out.print(red);
if(mod > 0){
mod--;
System.out.print("R");
}
System.out.print("B");
}
System.out.print(red);
System.out.println();
}
}
public static long gcd(long a,long b){
if(b == 0){
return a;
}
return gcd(b,a%b);
}
}
class Pair implements Comparable<Pair>{
int x;
int y;
Pair(int x,int y){
this.x = x;
this.y = y;
}
@Override
public int compareTo(Pair p){
return this.x-p.x;
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | ef675de7f4c3ebbc071a39b2d321a18c | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.io.*;
import java.util.*;
public class A {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
PrintWriter pw = new PrintWriter(System.out);
int t = in.nextInt();
for (int tt = 0; tt < t; tt++) {
int n = in.nextInt(), r = in.nextInt(), b = in.nextInt();
if (b == 1) {
char[] a = new char[n];
a[(n / 2)] = 'B';
for (int i = 0; i < n; i++) if (a[i] != 'B') a[i] = 'R';
for (char c: a) pw.print(c);
pw.println();
continue;
}
int cntR = r / (b + 1);
int extra = r % (b + 1);
ArrayDeque<Character> dq = new ArrayDeque<>();
for (int i = 0; i < b; i++) {
dq.add('B');
for (int j = 0; j < cntR; j++) dq.add('R');
}
for (int i = 0; i < cntR; i++) dq.addFirst('R');
for (char c: dq) {
pw.print(c);
if (c == 'B' && extra > 0) {
pw.print('R');
extra--;
}
}
pw.println();
}
pw.close();
}
static void debug(Object... obj) {
System.err.println(Arrays.deepToString(obj));
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | 362d5e9877c34e40c11b6916aef18917 | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
public class div {
public static void main(String[] args) throws Exception {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t-->0){
int n=sc.nextInt();
int r=sc.nextInt();
int b=sc.nextInt();
int[] a=new int[b];
loop: while (true){
for (int i = 0; i <b ; i++) {
if(a[i]<r) {
a[i]++;
r--;
}
else
break loop;
}
}
for (int i = 0; i <b ; i++) {
while (a[i]>0){
System.out.print("R");
a[i]--;
}
System.out.print("B");
}
while (r>0){
r--;
System.out.print("R");
}
System.out.println();
}
}
}
| Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output | |
PASSED | c7db1c75045e612d2a3a8baee94fde6b | train_110.jsonl | 1650206100 | Team Red and Team Blue competed in a competitive FPS. Their match was streamed around the world. They played a series of $$$n$$$ matches.In the end, it turned out Team Red won $$$r$$$ times and Team Blue won $$$b$$$ times. Team Blue was less skilled than Team Red, so $$$b$$$ was strictly less than $$$r$$$.You missed the stream since you overslept, but you think that the match must have been neck and neck since so many people watched it. So you imagine a string of length $$$n$$$ where the $$$i$$$-th character denotes who won the $$$i$$$-th match — it is R if Team Red won or B if Team Blue won. You imagine the string was such that the maximum number of times a team won in a row was as small as possible. For example, in the series of matches RBBRRRB, Team Red won $$$3$$$ times in a row, which is the maximum.You must find a string satisfying the above conditions. If there are multiple answers, print any. | 256 megabytes | import java.util.Scanner;
public class Main {
public static void main(String[] args) {
try (Scanner scanner = new Scanner(System.in)) {
int t = Integer.parseInt(scanner.nextLine());
for (; t > 0; t--) {
String[] line = scanner.nextLine().split(" ");
int n = Integer.parseInt(line[0]);
int r = Integer.parseInt(line[1]);
int b = Integer.parseInt(line[2]);
n -= b;
int rp = (int)Math.ceil((r) / (b + 1.0));
StringBuilder rrp = new StringBuilder(rp);
for (int i = 0; i < rp; i++) {
rrp.append("R");
}
String rrps = rrp.toString();
StringBuilder stringBuilder = new StringBuilder(n);
while (r >= rp) {
stringBuilder.append(rrps);
if (b > 0) {
stringBuilder.append("B");
}
b--;
r -= rp;
if (b >= 0 && r % (b + 1) == 0) {
rp = (int)((r) / (b + 1.0));
rrp = new StringBuilder(rp);
for (int i = 0; i < rp; i++) {
rrp.append("R");
}
rrps = rrp.toString();
}
}
for (int i = 0; i < r; i++) {
stringBuilder.append("R");
}
for (int i = 0; i < b; i++) {
stringBuilder.append("B");
}
System.out.println(stringBuilder.toString());
}
}
}
} | Java | ["3\n7 4 3\n6 5 1\n19 13 6", "6\n3 2 1\n10 6 4\n11 6 5\n10 9 1\n10 8 2\n11 9 2"] | 1 second | ["RBRBRBR\nRRRBRR\nRRBRRBRRBRRBRRBRRBR", "RBR\nRRBRBRBRBR\nRBRBRBRBRBR\nRRRRRBRRRR\nRRRBRRRBRR\nRRRBRRRBRRR"] | NoteThe first test case of the first example gives the optimal answer for the example in the statement. The maximum number of times a team wins in a row in RBRBRBR is $$$1$$$. We cannot minimize it any further.The answer for the second test case of the second example is RRBRBRBRBR. The maximum number of times a team wins in a row is $$$2$$$, given by RR at the beginning. We cannot minimize the answer any further. | Java 8 | standard input | [
"constructive algorithms",
"greedy",
"implementation",
"math"
] | 7cec27879b443ada552a6474c4e45c30 | The first line contains a single integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. Each test case has a single line containing three integers $$$n$$$, $$$r$$$, and $$$b$$$ ($$$3 \leq n \leq 100$$$; $$$1 \leq b < r \leq n$$$, $$$r+b=n$$$). | 1,000 | For each test case, output a single line containing a string satisfying the given conditions. If there are multiple answers, print any. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.