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 listlengths 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 | 74faa990424767d756d0b7ffade6f100 | train_000.jsonl | 1482165300 | Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer diviso... | 256 megabytes | import java.util.*;
public class arr{
static void func(int n){
if(n%2==0){
System.out.println(n/2);
for(int i=1;i<=n/2;i++){
System.out.print(2+" ");
}
}else{
int notwos=(n/2)-1;
System.out.println(n/2);
for(int i=1;i<=notwos;i++){
System.out.print(2+" ");
}
S... | Java | ["5", "6"] | 1 second | ["2\n2 3", "3\n2 2 2"] | null | Java 11 | standard input | [
"implementation",
"number theory",
"greedy",
"math"
] | 98fd00d3c83d4b3f0511d8afa6fdb27b | The only line of the input contains a single integer n (2 ≤ n ≤ 100 000). | 800 | The first line of the output contains a single integer k — maximum possible number of primes in representation. The second line should contain k primes with their sum equal to n. You can print them in any order. If there are several optimal solution, print any of them. | standard output | |
PASSED | 0aaf7e1d6e9d51dd4bcb3c350b635dab | train_000.jsonl | 1482165300 | Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer diviso... | 256 megabytes |
import java.util.*;
import static java.lang.System.out;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
impo... | Java | ["5", "6"] | 1 second | ["2\n2 3", "3\n2 2 2"] | null | Java 11 | standard input | [
"implementation",
"number theory",
"greedy",
"math"
] | 98fd00d3c83d4b3f0511d8afa6fdb27b | The only line of the input contains a single integer n (2 ≤ n ≤ 100 000). | 800 | The first line of the output contains a single integer k — maximum possible number of primes in representation. The second line should contain k primes with their sum equal to n. You can print them in any order. If there are several optimal solution, print any of them. | standard output | |
PASSED | afdefd3574ba76566ed25ffc28143fe0 | train_000.jsonl | 1482165300 | Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer diviso... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class Main {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new BufferedReader(new
... | Java | ["5", "6"] | 1 second | ["2\n2 3", "3\n2 2 2"] | null | Java 11 | standard input | [
"implementation",
"number theory",
"greedy",
"math"
] | 98fd00d3c83d4b3f0511d8afa6fdb27b | The only line of the input contains a single integer n (2 ≤ n ≤ 100 000). | 800 | The first line of the output contains a single integer k — maximum possible number of primes in representation. The second line should contain k primes with their sum equal to n. You can print them in any order. If there are several optimal solution, print any of them. | standard output | |
PASSED | 4c46ab8c832af475f9e769723447c6a0 | train_000.jsonl | 1482165300 | Bachgold problem is very easy to formulate. Given a positive integer n represent it as a sum of maximum possible number of prime numbers. One can prove that such representation exists for any integer greater than 1.Recall that integer k is called prime if it is greater than 1 and has exactly two positive integer diviso... | 256 megabytes | import java.io.*;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(System.out);
int n = Integer.parseInt(in.readLine());
out.println(n / 2);
... | Java | ["5", "6"] | 1 second | ["2\n2 3", "3\n2 2 2"] | null | Java 11 | standard input | [
"implementation",
"number theory",
"greedy",
"math"
] | 98fd00d3c83d4b3f0511d8afa6fdb27b | The only line of the input contains a single integer n (2 ≤ n ≤ 100 000). | 800 | The first line of the output contains a single integer k — maximum possible number of primes in representation. The second line should contain k primes with their sum equal to n. You can print them in any order. If there are several optimal solution, print any of them. | standard output | |
PASSED | ae2961a5955dd4df747511c7d788a841 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main
{
public static void main(String[] args)
{
FastReader reader = new FastReader();
PrintWriter writer = new PrintWriter(System.out);
int n = reader.nextInt();
int[] count = new int[n];
boolean ans = true;
for (int i=1; i<n; i++)
{
int x = re... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 57479d047a49e9f119d9ff305c0091ab | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes |
import java.io.*;
import java.util.*;
/**
* Copyright © 2018 Chris. All rights reserved.
*
* @author Chris
* 2018/7/9 15:33
* @see format
*/
public class E {
private static BufferedReader br;
private static StreamTokenizer st;
private static PrintWriter pw;
private static void solve() throws I... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | c18d70b117e287be1000ea1bbfddd43e | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | //package sept;
import java.io.*;
import java.util.*;
public class CodeAgon {
InputStream is;
PrintWriter out;
String INPUT = "";
//boolean debug=true;
boolean debug=false;
void solve()
{
int n=ni();
int[] a=new int[n-1];
for(int i=0;i<n-1;i++)
{
int u=ni(),v=ni();
if(v!=n)
... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | c08e419454a9cc0c55b223da0b58360b | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | /* Author: Ronak Agarwal, reader part not written by me*/
import java.io.* ; import java.util.* ;
import static java.lang.Math.min ; import static java.lang.Math.max ;
import static java.lang.Math.abs ; import static java.lang.Math.log ;
import static java.lang.Math.pow ; import static java.lang.Math.sqrt ;
/* Thread i... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 4710d6cbdbb5c3ab4d8e82963c480ffb | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws FileNotFoundException {
ConsoleIO io = new ConsoleIO(new InputStreamReader(System.in), new PrintWriter(System.out));
// String fileName = "C-small-attempt0";
// ConsoleIO io = new ConsoleI... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 359b8527199d2677fd60c29ec474e265 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class tr1 {
static PrintWriter out;
static StringBuilder sb;
static int inf = (int) 1e9;
static long mod = (long) 998244353;
static int[] si;
static ArrayList<Integer> primes;
static HashSet<Integer> pr;
static int n, k, m;
static int[] in;
static HashMap<Integer,... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 9e049ee67b483604387f9bc1ff0ff8a4 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | //package com.company;
import java.io.*;
import java.util.*;
public class Main {
static long TIME_START, TIME_END;
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
// Scanner sc = new Scanner(new FileInputStream("Test.in"));
PrintWriter p... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 16b652edd52beb708332c389d85c1797 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.*;
import java.util.*;
import java.text.*;
import java.lang.*;
import java.math.*;
public class Main{
static ArrayList[] a = new ArrayList[200001];
public void solve () throws IOException {
InputReader in = new InputReader(System.in);
PrintWriter pw = new PrintWriter(Sys... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 1af410b6f0cdb0f374a7fd161bb31637 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.*;
import java.util.*;
import java.util.LinkedList;
import java.math.*;
import java.lang.*;
import java.util.PriorityQueue;
import static java.lang.Math.*;
@SuppressWarnings("unchecked")
public cla... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 2bf736e5e2ca3623b584cfe60a90ca05 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.HashMap;
import ... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 391caf07d686c55f11b98f16c165c58c | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.PriorityQueue;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @au... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | d7e56acf2907c533850da3321b8b4494 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | /**
* BaZ :D
*/
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
public class Main
{
static Reader scan;
static PrintWriter pw;
public static void main(String[] args) {
new Thread(null,null,"BaZ",1<<25)
{
public void run()
{
try
... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | bff3f1afbeb104194df0a564e3a62049 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.BufferedWriter;
import java.util.Set;
import java.util.InputMismatchException;
import java.io.IOException;
import java.util.TreeSet;
impor... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 7e95252d1892ae5775148416992a9809 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.util.*;
import java.io.*;
import java.text.*;
//Solution Credits: Taranpreet Singh
public class Main{
//SOLUTION BEGIN
void solve(int TC) throws Exception{
int n = ni();
int[][] e = new int[n-1][];
boolean valid = true;
for(int i = 0; i< n-1; i++){
e[i] =... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 4209583b679e29a9c63720eb3f02919e | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;
import java.util.*;
public class A3 {
public s... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 3878056eb12d9810f33a3107af6f9e26 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.math.*;
import java.io.*;
import static java.lang.Math.*;
/* spar5h */
//hm.get((long)0) != hm.get(0)
public class cf5 implements Runnable{
static class pair {
int i, j;
pair(int i, int j) {
this.i = i; this.j = j;
}
}
static class comp im... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | aab320efa7dd130548bb3caf551dc23e | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Task {
public static void main(String[] args) throws Exception {
new Task().go();
}
PrintWriter out;
Reader in;
BufferedReader br;
Task() throws IOException {
try {
//br = new BufferedReader( new FileReader("in... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 3a13f6fd3c1b8aa40e615d128a0f39da | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static int MOD = 1000000007;
// After writing solution, quick scan for:
// array out of bounds
// special cases e.g. n=1?
//
// Big numbers arithmetic bugs:
// int overflow
// sorting, or tak... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | a93025bff045b686dcee1555a92cd155 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.util.TreeSet;
import java.util.ArrayList;
import java.io.InputStream;
/**
* @author khokharnikunj8
*/
public class Main {... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | d5008e3a3b05ee31681241abe4f050fd | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;
import java.util.Map.Entry;
public class Main
{
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 2512bc5a97994155131789b5b2b648da | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class E {
FastScanner in;
PrintWriter out;
boolean systemIO = true;
public class Pair {
int v;
int place;
public Pair(int v, int place) {
this.v = v;
this.place = place;
}
}
public void solve() {
int n = in.nextInt();... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | b2324c6fb60f387d3cb56a18d750bf9a | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void main(String args[]) {new Main().run();}
FastReader in = new FastReader();
PrintWriter out = new PrintWriter(System.out);
void run(){
work();
out.flush();
}
long mod=998244353L;
int ret=99999999;
void work() {
int n=i... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | b0d09e9c9a5534a8d8552f7db1ffc296 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.awt.Point;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.PriorityQueue;
import java.util.Scanner;
public class E1041 {
static int N;
public static void main(String args[]) throws Exception {
Scanner in ... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 20544c7b724a8433774ddf5f11ff0564 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | //package que_a;
import java.io.*;
import java.util.*;
import java.math.*;
public class utkarsh {
InputStream is;
PrintWriter out;
long mod = (long) (1e9 + 7), inf = (long) (3e15);
boolean SHOW_TIME, debug;
class pair {
int F, S;
pair(int f, int s) {
F = f; ... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | f3f0a4af4ea6bb344674454e51d170b6 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.*;
import java.math.*;
import java.text.*;
import java.util.*;
import java.util.regex.*;
public class Solution
{
static class InputReader
{
private final InputStream stream;
private final byte[] buf = new byte[8192];
private int curChar, snumChars;
public InputR... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | b758ab22b3a1ad4cb358c78b6bbb3575 | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
private void solve() throws IOException {
int n = readInt();
int[] a = new int[n];
int[] cnt = new int[n];
for (int i = 0; i < n - 1; i++) {
int x = readInt() - 1;
int y = readInt() - 1;
a[... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | 6890ed4ae060b9c2cfba59c760dae99e | train_000.jsonl | 1537094100 | Monocarp has drawn a tree (an undirected connected acyclic graph) and then has given each vertex an index. All indices are distinct numbers from $$$1$$$ to $$$n$$$. For every edge $$$e$$$ of this tree, Monocarp has written two numbers: the maximum indices of the vertices of the two components formed if the edge $$$e$$$... | 256 megabytes | import java.lang.*;
import java.math.*;
import java.util.*;
import java.io.*;
public class Main {
void solve(){
int n=ni();
int cnt[]=new int[n+1];
for(int i=1;i<n;i++){
int a=ni(),b=ni();
if(b!=n) {
pw.println("NO");
return;
... | Java | ["4\n3 4\n1 4\n3 4", "3\n1 3\n1 3", "3\n1 2\n2 3"] | 1 second | ["YES\n1 3\n3 2\n2 4", "NO", "NO"] | NotePossible tree from the first example. Dotted lines show edges you need to remove to get appropriate pairs. | Java 8 | standard input | [
"data structures",
"constructive algorithms",
"greedy",
"graphs"
] | 531746ba8d93a76d5bdf4bab67d9ba19 | The first line contains one integer $$$n$$$ ($$$2 \le n \le 1\,000$$$) — the number of vertices in the tree. Each of the next $$$n-1$$$ lines contains two integers $$$a_i$$$ and $$$b_i$$$ each ($$$1 \le a_i < b_i \le n$$$) — the maximal indices of vertices in the components formed if the $$$i$$$-th edge is removed. | 1,900 | If there is no such tree that can produce the given list of pairs, print "NO" (without quotes). Otherwise print "YES" (without quotes) in the first line and the edges of the tree in the next $$$n - 1$$$ lines. Each of the last $$$n - 1$$$ lines should contain two integers $$$x_i$$$ and $$$y_i$$$ ($$$1 \le x_i, y_i \le ... | standard output | |
PASSED | f248b8628ed30153673d8e46ba67e803 | train_000.jsonl | 1331280000 | Little Janet likes playing with cubes. Actually, she likes to play with anything whatsoever, cubes or tesseracts, as long as they are multicolored. Each cube is described by two parameters — color ci and size si. A Zebra Tower is a tower that consists of cubes of exactly two colors. Besides, the colors of the cubes in ... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
i... | Java | ["4\n1 2\n1 3\n2 4\n3 3", "2\n1 1\n2 1"] | 1.5 seconds | ["9\n3\n2 3 1", "2\n2\n2 1"] | null | Java 7 | standard input | [
"data structures",
"sortings",
"*special",
"greedy"
] | fa867bb7df94cc0edc03bcbf975de001 | The first line contains an integer n (2 ≤ n ≤ 105) — the number of cubes. Next n lines contain the descriptions of the cubes, one description per line. A cube description consists of two space-separated integers ci and si (1 ≤ ci, si ≤ 109) — the i-th cube's color and size, correspondingly. It is guaranteed that there ... | 1,700 | Print the description of the Zebra Tower of the maximum height in the following form. In the first line print the tower's height, in the second line print the number of cubes that form the tower, and in the third line print the space-separated indices of cubes in the order in which they follow in the tower from the bot... | standard output | |
PASSED | ca6becd515afe5558c4bed21419bfaa4 | train_000.jsonl | 1331280000 | Little Janet likes playing with cubes. Actually, she likes to play with anything whatsoever, cubes or tesseracts, as long as they are multicolored. Each cube is described by two parameters — color ci and size si. A Zebra Tower is a tower that consists of cubes of exactly two colors. Besides, the colors of the cubes in ... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
public class Main {
static cl... | Java | ["4\n1 2\n1 3\n2 4\n3 3", "2\n1 1\n2 1"] | 1.5 seconds | ["9\n3\n2 3 1", "2\n2\n2 1"] | null | Java 7 | standard input | [
"data structures",
"sortings",
"*special",
"greedy"
] | fa867bb7df94cc0edc03bcbf975de001 | The first line contains an integer n (2 ≤ n ≤ 105) — the number of cubes. Next n lines contain the descriptions of the cubes, one description per line. A cube description consists of two space-separated integers ci and si (1 ≤ ci, si ≤ 109) — the i-th cube's color and size, correspondingly. It is guaranteed that there ... | 1,700 | Print the description of the Zebra Tower of the maximum height in the following form. In the first line print the tower's height, in the second line print the number of cubes that form the tower, and in the third line print the space-separated indices of cubes in the order in which they follow in the tower from the bot... | standard output | |
PASSED | 86951739be377540b4136ee6bc72b5f0 | train_000.jsonl | 1331280000 | Little Janet likes playing with cubes. Actually, she likes to play with anything whatsoever, cubes or tesseracts, as long as they are multicolored. Each cube is described by two parameters — color ci and size si. A Zebra Tower is a tower that consists of cubes of exactly two colors. Besides, the colors of the cubes in ... | 256 megabytes | import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String[] argv) {
new Main().run();
}
void run() {
in = new Scanner(System.in);
out = new PrintWriter(Sy... | Java | ["4\n1 2\n1 3\n2 4\n3 3", "2\n1 1\n2 1"] | 1.5 seconds | ["9\n3\n2 3 1", "2\n2\n2 1"] | null | Java 7 | standard input | [
"data structures",
"sortings",
"*special",
"greedy"
] | fa867bb7df94cc0edc03bcbf975de001 | The first line contains an integer n (2 ≤ n ≤ 105) — the number of cubes. Next n lines contain the descriptions of the cubes, one description per line. A cube description consists of two space-separated integers ci and si (1 ≤ ci, si ≤ 109) — the i-th cube's color and size, correspondingly. It is guaranteed that there ... | 1,700 | Print the description of the Zebra Tower of the maximum height in the following form. In the first line print the tower's height, in the second line print the number of cubes that form the tower, and in the third line print the space-separated indices of cubes in the order in which they follow in the tower from the bot... | standard output | |
PASSED | 30633b9aa7d8a4c6aba9731a9be46d4e | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
public class beautifulString {
//FastScanner for Java
public static class FastScanner {
BufferedReader br;
StringTokenizer st;
public FastScanner() {
br = new BufferedReader(n... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 89ef1dc6d970134fc40b62f67854e77f | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
// import java.text.DecimalFormat;
public class test{
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReader(new InputStreamReader(System.in));
}
... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | ec5f1b4b9e42f48e6590597797243e57 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.util.*;
public class JavaApplication2{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt();
scan.nextLine();
String[] str = new String[n];
for (int i = 0; i < n; i++) {
boolean f = true;
... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | c66d5f30215af7f0d7ffac0fa5d34470 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes |
import java.io.*;
import java.util.*;
import java.lang.*;
public class s {
public static void main (String[] args) throws java.lang.Exception {
try {
Scanner sc = new Scanner(System.in);
int t = sc.nextInt();
while(t-->0){
String s = sc.next();
int n = s.length... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 855f29ca5da72af1547b053f7262153c | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | //package cf1;
import java.io.*;
import java.util.*;
public class utkarsh {
BufferedReader br;
PrintWriter out;
long mod = (long) (1e9 + 7), inf = (long) (3e18);
void solve() {
int t = ni();
while(t-- > 0) {
char s[] = ns().toCharArray();
int n =... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | e85202be5004fcc7f4371aad56a1471b | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
long k;
void run(FastIO io) {
int n = io.nextInt();
String next;
char last, now;
StringBuilder sb;
boolean end;
for (int i = 0; i < n; i++) {
next = io.nextToken();
sb = new Strin... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 305377156cf9466411595e24df25f929 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class BeautifulString {
public static void main(String[] args) throws NumberFormatException, IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int testcase = Integer.parse... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | e7249886982cce8c67912d960d7446e7 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.*;
import java.util.*;
import javafx.util.Pair;
public class HR27 {
InputStream is;
PrintWriter out;
String INPUT = "";
//boolean codechef=true;
boolean codechef=true;
void solve()
{
int n = ni();
for(int i=0;i<n;i++)
{
String s=ns();
char[] ans=s.toCharArray();... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | c16c3cf0a683f0ff85898c3b2a643d04 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.util.*;
import java.io.*;
public class q1{
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int test = scan.nextInt();
while(test-->0){
String str = scan.next();
int n = str.length();
char ch[] = str.toCharArray()... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | dfc08328273393e89ace19d9d3847a57 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class ProblemA {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextLine()) {
int number = Integer.parseInt(scanner.nextLine().trim());
for (int k =... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 342b8b2be3471e026f2ec822f1cad487 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.util.*;
import java.io.*;
public class A{
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
PrintWriter pw=new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
int tc=Integer.parseInt(br.readLine()... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 61db87068d0ccc754c657a6561dc3ff3 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
while(n-->0)
{
char[] arr=sc.next().toCharArray();
int l=arr.length;
if(arr[0]=='?')
{
if(l>1)
{
if(arr[1]=='a'||arr[... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 71c46c91f4352ffa70245e7ed9fa93d4 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Contest604_Div2_AProblem_ {
static BufferedReader br;
static StringBuilder ar;
public static void main(String[] args) throws NumberFormatException, IOException {
br = new BufferedReader(new InputStreamRead... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 370d9e7ddf285a38d8120bc651e7e453 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Contest604_Div2_AProblem {
static BufferedReader br;
static String ar[];
public static void main(String[] args) throws NumberFormatException, IOException {
br = new ... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 1b8eaca865f508c069107de29c8a5c6e | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | //package com.company;
import java.io.*;
import java.util.*;
import java.lang.*;
public class Main{
public static class FastReader {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;
... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 29306dc6d50a25a44c6bfdc3c62ef70f | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.*;
/* 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
{
FastReader ... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | d9691823f8059d74e6d6356ca0413812 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
public class Solver {
public static void main(String[] args) throws IOException {
br = new BufferedReader(new InputStreamReader(System.in));
pw = new PrintWriter(System.out);
// br = new BufferedReader(new FileReader("dat... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 5f99c120c4f70021161b81045df56050 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.util.*;
public class S {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int i=0;i<t;i++)
{
String s=sc.next();
StringBuilder sb=new StringBuilder(s);
int flag=0;
if(s.con... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | a548cd8e4a8ef74fab8211bd05a1d682 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.util.*;
import java.io.*;
public class A {
public static void main(String[] args) {
FastScanner sc = new FastScanner();
int T = sc.nextInt();
PrintWriter pw = new PrintWriter(System.out);
for(int t = 0; t < T; t++) {
char[] s = sc.next().toCharArray();
int n = s.length;
for(int i = 0; i ... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 452971b227c6b9f1130fc67f6701a746 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
import java.util.StringTokenizer;
/**
* Created by flk on 2019/12/8.
*/
public class Main {
public static void main(String[] args) {
Inp... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | a67d6896cecdeca8917bd69f82cb91e9 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
public class A {
private static String findVal(String a) {
char[] ar = a.toCharArray();
int n = ar.length;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
if (i < n - 1)... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | b8a946594109ab527e7c0eb640a5a3d5 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.io.File;
import java.io.FileNotFoundException;
import java.util.*;
public class A {
private static String findVal(String a) {
char[] ar = a.toCharArray();
int n = ar.length;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; i++) {
if (i < n - 1)... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | ceae8e4359f5ccad69ca7ecf6f331bab | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes |
import java.util.*;
import java.io.*;
import java.math.*;
public class q4 {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
int n=Integer.parseInt(reader.readLine());
while(n-->0) {
String tt=reader.read... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 6eaafde052b698cd2d5ad4d8b7c31970 | train_000.jsonl | 1575556500 | A string is called beautiful if no two consecutive characters are equal. For example, "ababcb", "a" and "abab" are beautiful strings, while "aaaaaa", "abaa" and "bb" are not.Ahcl wants to construct a beautiful string. He has a string $$$s$$$, consisting of only characters 'a', 'b', 'c' and '?'. Ahcl needs to replace ea... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution {
public static void main (String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
// String[] temp=br.readLine().trim().split(" ");
int numTestCases=Integer.parseInt(br.readLine());
while(numTestCa... | Java | ["3\na???cb\na??bbc\na?b?c"] | 1 second | ["ababcb\n-1\nacbac"] | NoteIn the first test case, all possible correct answers are "ababcb", "abcacb", "abcbcb", "acabcb" and "acbacb". The two answers "abcbab" and "abaabc" are incorrect, because you can replace only '?' characters and the resulting string must be beautiful.In the second test case, it is impossible to create a beautiful st... | Java 8 | standard input | [
"constructive algorithms",
"greedy"
] | 98c08a3b5e5b5bb78804ff797ba24d87 | The first line contains positive integer $$$t$$$ ($$$1 \leq t \leq 1000$$$) — the number of test cases. Next $$$t$$$ lines contain the descriptions of test cases. Each line contains a non-empty string $$$s$$$ consisting of only characters 'a', 'b', 'c' and '?'. It is guaranteed that in each test case a string $$$s$$$ ... | 1,000 | For each test case given in the input print the answer in the following format: If it is impossible to create a beautiful string, print "-1" (without quotes); Otherwise, print the resulting beautiful string after replacing all '?' characters. If there are multiple answers, you can print any of them. | standard output | |
PASSED | 636496ed547a8e979199c5a11fc29e3a | train_000.jsonl | 1407690000 | The game of bingo is played on a 5 × 5 square grid filled with distinct numbers between 1 and 75. In this problem you will consider a generalized version played on an n × n grid with distinct numbers between 1 and m (m ≥ n2). A player begins by selecting a randomly generated bingo grid (generated uniformly among all av... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
* @author Popa Andrei
*/
public class Main {
public static void main(String[] args) {
InputS... | Java | ["1 2 1", "2 4 3", "7 59164 40872"] | 1 second | ["2.5", "4", "3.1415926538"] | null | Java 7 | standard input | [
"combinatorics",
"probabilities"
] | 60f3c7528ee169be4ce63441802fec6b | Input will consist of three integers n, m, k (1 ≤ n ≤ 300; n2 ≤ m ≤ 100000; n ≤ k ≤ m). | 2,700 | Print the smaller of 1099 and the expected score. Your answer must be correct within an absolute or relative error of 10 - 9. | standard output | |
PASSED | 5268bfd4e7eb0bace48658136d5a0a25 | train_000.jsonl | 1407690000 | The game of bingo is played on a 5 × 5 square grid filled with distinct numbers between 1 and 75. In this problem you will consider a generalized version played on an n × n grid with distinct numbers between 1 and m (m ≥ n2). A player begins by selecting a randomly generated bingo grid (generated uniformly among all av... | 256 megabytes | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static ... | Java | ["1 2 1", "2 4 3", "7 59164 40872"] | 1 second | ["2.5", "4", "3.1415926538"] | null | Java 7 | standard input | [
"combinatorics",
"probabilities"
] | 60f3c7528ee169be4ce63441802fec6b | Input will consist of three integers n, m, k (1 ≤ n ≤ 300; n2 ≤ m ≤ 100000; n ≤ k ≤ m). | 2,700 | Print the smaller of 1099 and the expected score. Your answer must be correct within an absolute or relative error of 10 - 9. | standard output | |
PASSED | 5079180b41227bd60e3ee6357f9a921f | train_000.jsonl | 1407690000 | The game of bingo is played on a 5 × 5 square grid filled with distinct numbers between 1 and 75. In this problem you will consider a generalized version played on an n × n grid with distinct numbers between 1 and m (m ≥ n2). A player begins by selecting a randomly generated bingo grid (generated uniformly among all av... | 256 megabytes | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static ... | Java | ["1 2 1", "2 4 3", "7 59164 40872"] | 1 second | ["2.5", "4", "3.1415926538"] | null | Java 7 | standard input | [
"combinatorics",
"probabilities"
] | 60f3c7528ee169be4ce63441802fec6b | Input will consist of three integers n, m, k (1 ≤ n ≤ 300; n2 ≤ m ≤ 100000; n ≤ k ≤ m). | 2,700 | Print the smaller of 1099 and the expected score. Your answer must be correct within an absolute or relative error of 10 - 9. | standard output | |
PASSED | 2710c1a2f587f23cd6aa220f81141407 | train_000.jsonl | 1407690000 | The game of bingo is played on a 5 × 5 square grid filled with distinct numbers between 1 and 75. In this problem you will consider a generalized version played on an n × n grid with distinct numbers between 1 and m (m ≥ n2). A player begins by selecting a randomly generated bingo grid (generated uniformly among all av... | 256 megabytes | import java.io.InputStreamReader;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
public static ... | Java | ["1 2 1", "2 4 3", "7 59164 40872"] | 1 second | ["2.5", "4", "3.1415926538"] | null | Java 7 | standard input | [
"combinatorics",
"probabilities"
] | 60f3c7528ee169be4ce63441802fec6b | Input will consist of three integers n, m, k (1 ≤ n ≤ 300; n2 ≤ m ≤ 100000; n ≤ k ≤ m). | 2,700 | Print the smaller of 1099 and the expected score. Your answer must be correct within an absolute or relative error of 10 - 9. | standard output | |
PASSED | 6a26aee361b014a60d163411fa218568 | train_000.jsonl | 1321337400 | One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but at this point her youn... | 256 megabytes | import java.util.Map;
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.HashMap;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.Random;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top... | Java | ["4\n1 2 3 2", "6\n1 1 2 2 2 3", "6\n2 4 1 1 2 2"] | 2 seconds | ["YES", "YES", "NO"] | null | Java 7 | standard input | [
"constructive algorithms",
"implementation"
] | de41c260a37ec9db2371efb9d246a470 | The first line contains an integer n — how many numbers Anna had (3 ≤ n ≤ 105). The next line contains those numbers, separated by a space. All numbers are integers and belong to the range from 1 to 109. | 2,000 | Print the single line "YES" (without the quotes), if Anna could have completed the task correctly using all those numbers (using all of them is necessary). If Anna couldn't have fulfilled the task, no matter how hard she would try, print "NO" (without the quotes). | standard output | |
PASSED | 361f6c6e955b146471145a7fe158fa0c | train_000.jsonl | 1321337400 | One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but at this point her youn... | 256 megabytes | import java.io.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.util.TreeSet;
public class Main {
public static void main(String[... | Java | ["4\n1 2 3 2", "6\n1 1 2 2 2 3", "6\n2 4 1 1 2 2"] | 2 seconds | ["YES", "YES", "NO"] | null | Java 7 | standard input | [
"constructive algorithms",
"implementation"
] | de41c260a37ec9db2371efb9d246a470 | The first line contains an integer n — how many numbers Anna had (3 ≤ n ≤ 105). The next line contains those numbers, separated by a space. All numbers are integers and belong to the range from 1 to 109. | 2,000 | Print the single line "YES" (without the quotes), if Anna could have completed the task correctly using all those numbers (using all of them is necessary). If Anna couldn't have fulfilled the task, no matter how hard she would try, print "NO" (without the quotes). | standard output | |
PASSED | 26d8ce2f2b4cf2258d5638a7f84ea2c8 | train_000.jsonl | 1321337400 | One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but at this point her youn... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
public class D94 {
static StringTokenizer st;
static Buffer... | Java | ["4\n1 2 3 2", "6\n1 1 2 2 2 3", "6\n2 4 1 1 2 2"] | 2 seconds | ["YES", "YES", "NO"] | null | Java 7 | standard input | [
"constructive algorithms",
"implementation"
] | de41c260a37ec9db2371efb9d246a470 | The first line contains an integer n — how many numbers Anna had (3 ≤ n ≤ 105). The next line contains those numbers, separated by a space. All numbers are integers and belong to the range from 1 to 109. | 2,000 | Print the single line "YES" (without the quotes), if Anna could have completed the task correctly using all those numbers (using all of them is necessary). If Anna couldn't have fulfilled the task, no matter how hard she would try, print "NO" (without the quotes). | standard output | |
PASSED | ca94337e5ee9b0ef7b226cc2408393ed | train_000.jsonl | 1321337400 | One day Anna got the following task at school: to arrange several numbers in a circle so that any two neighboring numbers differs exactly by 1. Anna was given several numbers and arranged them in a circle to fulfill the task. Then she wanted to check if she had arranged the numbers correctly, but at this point her youn... | 256 megabytes | import java.util.*;
public class Main {
private static boolean solve() {
Scanner cin = new Scanner(System.in);
int N = 0;
int list[] = new int[100010];
int cnt[] = new int[100010];
int minNum = 1000000001;
int maxNum = -1;
N = cin.nextInt()... | Java | ["4\n1 2 3 2", "6\n1 1 2 2 2 3", "6\n2 4 1 1 2 2"] | 2 seconds | ["YES", "YES", "NO"] | null | Java 7 | standard input | [
"constructive algorithms",
"implementation"
] | de41c260a37ec9db2371efb9d246a470 | The first line contains an integer n — how many numbers Anna had (3 ≤ n ≤ 105). The next line contains those numbers, separated by a space. All numbers are integers and belong to the range from 1 to 109. | 2,000 | Print the single line "YES" (without the quotes), if Anna could have completed the task correctly using all those numbers (using all of them is necessary). If Anna couldn't have fulfilled the task, no matter how hard she would try, print "NO" (without the quotes). | standard output | |
PASSED | cdee7c9b59d8fa3dc3239f6c28c018ca | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author ca... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 7b82eb711cb5d8f6c05765177fe843ed | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.*;
import java.io.*;
public class coloring{
public static void main(String[] args) throws Exception {
BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
Scanner scan = new Scanner(System.in);
PrintWriter out = new PrintWriter(new OutputStreamWriter(System.o... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 9f142c1df55c0cc9dfc5f5623852a509 | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.*;
import java.io.*;
//import javafx.util.Pair;
public class Solution implements Runnable
{
class Pair implements Comparable <Pair>
{
long x,y;
Pair(long x,long y)
{
this.x=x;
this.y=y;
}
public int compareTo(Pair p)
... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 49b7af0fb791834c1d4071765819ebd5 | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int n = scan.nextInt(), k = scan.nextInt();
int[] arr = new int[5001];Arrays.fill(arr, 0);
Integer[][] arr1 = new Integer[n][2... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 90498ab01bf5b0b099f42fa6a666c28c | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
public static void solve(InputReader in ) {
int n = in.readInt(), k = in.readInt();
int a[] = new int[n];
int ans[] = new int[n];
int cnt[] = new int[50001];
for(int i = 0; i<n; i++)
a[i] = in.readInt();
int Max = 0;
for(int i =... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | a89ee530701578e0604524efb52b01fa | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.ArrayList;
import java.util.HashMap;
import java.util.Scanner;
import java.util.Set;
public class ArrayKcoloring1102_B {
public static void main(String[] args) {
Scanner s=new Scanner (System.in);
int n=s.nextInt();
int k=s.nextInt();
int[] array=new int[n];
HashMap<Integer,ArrayList<Inte... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 55706d058c74c6975879b605ebf28fae | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.io.*;
import java.util.*;
public class B {
public static void main(String[] args) throws IOException {
Scanner scn = new Scanner(System.in);
int n = scn.nextInt();
int k = scn.nextInt();
int a[] = new int[n];
HashMap<Integer, Integer> hm = new HashMap<>();
for (int i = 0; i < n; i++) {
a[i... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | ee4e1ce47846927a43c2e3216b5a0a41 | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | //package com.company;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.reflect.Array;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
Scanner s=new Scanner(... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | eb26849f523a64d369c35a4881493961 | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.*;
public class Eighteen
{
public static void main(String[] args) {
Scanner s=new Scanner(System.in);
int n=s.nextInt();
int k=s.nextInt();
int flag;
int input[][]=new int[n][2];
for(int i=0;i<n;i++){
input[i][0]=s.nextInt();
}
for(int i=1;i<=k;i++){
input[i-1][1]=i;
}
for(in... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 5917298db70b107a7237feab7d9244ea | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.List;
import java.util.Arrays;
import java.util.Map;
import java.util.Scanner;
import java.util.HashMap;
import java.util.Comparator;
import java.util.ArrayList;
/**
* Built using CHelper ... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | ea620525675e5e53175c215ee46463bc | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.Scanner;
public class ArrayKColoring {
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
int k = in.nextInt();
int[] ans = new int[n], ar = new int[n];
for(int i = 0; i < n; i++)
ar[i] = in.nextIn... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 76397168d6f0f3f773e7171fe4f4c4db | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
public static void main(String args[]) {
try{
new Solve().start();
}
catch(Exception e)
{
System.out.println(e);
System.exit(1);
}
}
}
cla... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | b051b8596c44ef333a7a43463eb4791e | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
public static void main(String args[]) {
try{
new Solve().start();
}
catch(Exception e)
{
System.out.println(e);
System.exit(1);
}
}
}
cla... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | f02b60a441a021000942168c9f1033cb | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
public static void main(String args[]) {
try{
new Solve().start();
}
catch(Exception e)
{
System.out.println(e);
System.exit(1);
}
}
}
cla... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | f705ed066beddb91c2ee7b85fb888115 | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
public static void main(String args[]) {
try{
new Solve().start();
}
catch(Exception e)
{
System.out.println(e);
System.exit(1);
}
}
}
cla... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | ca81bb1e9f01771c54b824444e084443 | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | import java.util.*;
import java.io.*;
import java.lang.*;
import java.math.*;
public class Main {
public static void main(String args[]) {
try{
new Solve().start();
}
catch(Exception e)
{
System.out.println(e);
System.exit(1);
}
}
}
cla... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 70bc509794ff90d6819ebb004b9c56f3 | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes |
import java.io.OutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;
//import java.math.*;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*/
public class Main {
static class Node implements C... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | a53843b152f95ea89dc9964aaf878fbf | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes |
/**
*
*/
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* @author moham
*
*/
public class B {
/**
* @param args
*/
public static void main(String[] args) {
Scanner scan... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | ec37f3743ae8a1847bc29d58f01004f4 | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes |
/**
* Date: 12 Jan, 2019
* Link:
*
* @author Prasad-Chaudhari
* @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/
* @git: https://github.com/Prasad-Chaudhari
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 444bc34c1ee04a225620c7379746e2e0 | train_000.jsonl | 1547044500 | You are given an array $$$a$$$ consisting of $$$n$$$ integer numbers.You have to color this array in $$$k$$$ colors in such a way that: Each element of the array should be colored in some color; For each $$$i$$$ from $$$1$$$ to $$$k$$$ there should be at least one element colored in the $$$i$$$-th color in the array... | 256 megabytes | //package codeforces.div2;
import java.util.*;
public class ArrayKColoring {
static public void print(int arr[], int k) {
HashMap<Integer, Integer> map = new HashMap<>();
int max = 0;
int va = 0;
for(int i = 0; i < arr.length; i++) {
map.put(arr[i], map.getOrDefault(a... | Java | ["4 2\n1 2 2 3", "5 2\n3 2 1 2 3", "5 2\n2 1 1 2 1"] | 2 seconds | ["YES\n1 1 2 2", "YES\n2 1 1 2 1", "NO"] | NoteIn the first example the answer $$$2~ 1~ 2~ 1$$$ is also acceptable.In the second example the answer $$$1~ 1~ 1~ 2~ 2$$$ is also acceptable.There exist other acceptable answers for both examples. | Java 8 | standard input | [
"sortings",
"greedy"
] | 3d4df21eebf32ce15841179bb85e6f2f | The first line of the input contains two integers $$$n$$$ and $$$k$$$ ($$$1 \le k \le n \le 5000$$$) — the length of the array $$$a$$$ and the number of colors, respectively. The second line of the input contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le 5000$$$) — elements of the array $$$a$$$. | 1,400 | If there is no answer, print "NO". Otherwise print "YES" and any coloring (i.e. numbers $$$c_1, c_2, \dots c_n$$$, where $$$1 \le c_i \le k$$$ and $$$c_i$$$ is the color of the $$$i$$$-th element of the given array) satisfying the conditions described in the problem statement. If there are multiple answers, you can pri... | standard output | |
PASSED | 87a4a4457643d9c9917b31d7a4dbec36 | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import java.io.*;
import java.util.Scanner;
public class Main
{
public static void main(String args[]) throws java.lang.Exception
{
//BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
String[] S;
File inFile=new File("input.txt");
Scanner sc=new Scanner(inFi... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | eb6723766c4c40f184a28655f3481845 | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | /**
* Created with IntelliJ IDEA.
* User: Venky
*/
import java.io.*;
import java.util.StringTokenizer;
public class Main {
static void solve() throws IOException {
int n = nextInt();
int m = nextInt();
StringBuffer sb = new StringBuffer();
if(n > m)
{
boolean... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | 9f937022030406371b0aec1e7d18ceca | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import static java.util.Arrays.deepToString;
import java.io.*;
import java.util.*;
public class Main {
static int binarySearch(int[] a, int x){
int n = a.length;
int left = -1;
int right = n;
while(right - left > 1){
int mid = (left + right) / 2;
if(x >... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | 971369d4f240d92b02e572a2b74c27b7 | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class practice {
public static void main(String[] args) {
Scanner sc = null;
try {
sc = new Scanner(new File("input.txt"));
} catch (FileNotFoundException e1) {
// TODO Auto-generated ca... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | e5538ebde80cf43b9d1cb5854c20e421 | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import java.util.*;
import java.io.*;
import java.math.BigInteger;
public class Main {
public static void main(String[] args) throws IOException {
Scanner scan = new Scanner (new File("input.txt"));
PrintStream out = new PrintStream (new File("output.txt"));
int b, q;
b = scan.nextInt(); q = scan.nextIn... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | 84c0ed16febce6040c97e667a27664b0 | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.StringTokenizer;
public class Main {
BufferedReader in;
StringTokeniz... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | 1058e76b02cef127de924743a1c433ac | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) throws Exception {
Scanner in = new Scanner(new File("input.txt"));
PrintWriter out = new PrintWriter(
new FileWriter(new File("output.txt")));
int n = in.nextInt();
int ... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | e802f176298eb8a1311e9105839ac1e9 | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.TreeMap;
public class Main {
... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | d65eaead2c9cd9152d9d52d99cb50ec9 | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | /*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
//package cf154;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.Scanner;
public class Cf154 {
public static void main(String[] args) throws FileNotFoundExce... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | 06a927c8b0b1fa00605e0437b9f98b2b | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
public class CF154D2A {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IO... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | 3e607184f35dfe99f8a3a2d37c409c4c | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | 4d007f1c96712b1df82c436ec5b105df | train_000.jsonl | 1354960800 | There are n boys and m girls studying in the class. They should stand in a line so that boys and girls alternated there as much as possible. Let's assume that positions in the line are indexed from left to right by numbers from 1 to n + m. Then the number of integers i (1 ≤ i < n + m) such that positions with indexe... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;
public class Main {
public static void main(String[] args) throws IOException {
(new Main()).solve();
}
public Main() {
}
//MyReader in = new MyReader();
//PrintWriter out = new PrintWriter(System.out);
void so... | Java | ["3 3", "4 2"] | 1 second | ["GBGBGB", "BGBGBB"] | NoteIn the first sample another possible answer is BGBGBG. In the second sample answer BBGBGB is also optimal. | Java 7 | input.txt | [
"greedy"
] | 5392996bd06bf52b48fe30b64493f8f5 | The single line of the input contains two integers n and m (1 ≤ n, m ≤ 100), separated by a space. | 1,100 | Print a line of n + m characters. Print on the i-th position of the line character "B", if the i-th position of your arrangement should have a boy and "G", if it should have a girl. Of course, the number of characters "B" should equal n and the number of characters "G" should equal m. If there are multiple optimal sol... | output.txt | |
PASSED | 1cca7f6b1bd6ecff6d96156712104952 | train_000.jsonl | 1531578900 | Let's call an undirected graph $$$G = (V, E)$$$ relatively prime if and only if for each edge $$$(v, u) \in E$$$ $$$GCD(v, u) = 1$$$ (the greatest common divisor of $$$v$$$ and $$$u$$$ is $$$1$$$). If there is no edge between some pair of vertices $$$v$$$ and $$$u$$$ then the value of $$$GCD(v, u)$$$ doesn't matter. T... | 256 megabytes | import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.math.RoundingMode;
import java.util.*;
import java.util.Map.Entry;
public class Main {
private InputStream stream;
private byte[] buf = new byte[1024];
private int curChar;
private int numChars;
private SpaceCharFilter filter;... | Java | ["5 6", "6 12"] | 2 seconds | ["Possible\n2 5\n3 2\n5 1\n3 4\n4 1\n5 4", "Impossible"] | NoteHere is the representation of the graph from the first example: | Java 8 | standard input | [
"greedy",
"graphs",
"constructive algorithms",
"math",
"brute force"
] | 0ab1b97a8d2e0290cda31a3918ff86a4 | The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10^5$$$) — the number of vertices and the number of edges. | 1,700 | If there exists no valid graph with the given number of vertices and edges then output "Impossible". Otherwise print the answer in the following format: The first line should contain the word "Possible". The $$$i$$$-th of the next $$$m$$$ lines should contain the $$$i$$$-th edge $$$(v_i, u_i)$$$ of the resulting graph ... | standard output | |
PASSED | 1fa3b34578d109b08d6f9ef78e637835 | train_000.jsonl | 1531578900 | Let's call an undirected graph $$$G = (V, E)$$$ relatively prime if and only if for each edge $$$(v, u) \in E$$$ $$$GCD(v, u) = 1$$$ (the greatest common divisor of $$$v$$$ and $$$u$$$ is $$$1$$$). If there is no edge between some pair of vertices $$$v$$$ and $$$u$$$ then the value of $$$GCD(v, u)$$$ doesn't matter. T... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main
{
static StringBuilder ans = new StringBuilder();
static StringBuilder ans1 = new StringBuilder();
static long mod = 1000000007;
static boolean[] primes;
static boolean co(int a, int b)
{
int min = Math.min(a, b);
for(int i=1;i<=min;i++)
{
if(primes... | Java | ["5 6", "6 12"] | 2 seconds | ["Possible\n2 5\n3 2\n5 1\n3 4\n4 1\n5 4", "Impossible"] | NoteHere is the representation of the graph from the first example: | Java 8 | standard input | [
"greedy",
"graphs",
"constructive algorithms",
"math",
"brute force"
] | 0ab1b97a8d2e0290cda31a3918ff86a4 | The only line contains two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 10^5$$$) — the number of vertices and the number of edges. | 1,700 | If there exists no valid graph with the given number of vertices and edges then output "Impossible". Otherwise print the answer in the following format: The first line should contain the word "Possible". The $$$i$$$-th of the next $$$m$$$ lines should contain the $$$i$$$-th edge $$$(v_i, u_i)$$$ of the resulting graph ... | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.