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
b2a5a2025bfba073d76fa51c7df41284
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.InputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatchException; import java.util.NoSuchElementException; import java.math.BigInteger; public class Main{ static PrintWriter out...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
59a0a52958a4cd031c9293b5746a16fe
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
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.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
d4615d8a92a1723bd1cc3cd67d6cfaf2
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.BufferedWriter; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.BitSet; import java.util.HashMap; import java.util.HashSet; public class Main { public static void main(String[] args) t...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
eb4b9a56aff73f3ee4a4685e11c139dc
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class C { static ArrayList<ArrayList<Integer>> g; stat...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
f2f5ed05dc96925de2d2efae8504d4ed
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.*; import java.util.*; public class C { public static void solution(BufferedReader reader, PrintWriter out) throws IOException { In in = new In(reader); n = in.nextInt(); int m = in.nextInt(); graph = new boolean[n][n]; for (int i = 0; i < m; i++) ...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
9b6919103c3c6bd632ae9913334da421
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; public class Main{ static boolean[][] adjMat; static ArrayList<Integer>[] adjList; static int[] color; static boolean bipartitie...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
b0d591c6efd271bb0ba1b469f5a44d3f
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; /** * * @author Sourav Kumar Paul */ public class SolveC { public static void main(String[] args) throws IOException{ Buffer...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
53c9841024d570da6ccf86ef46b85512
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class CF_624C { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int n = scan.nextInt(), m = scan.nextInt(); int[] degrees = new int[n]; ArrayList<Integer>[] edgeLists = new ArrayList[n]; fo...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
9fdd3d4dabe2a33537eeae33f29e0588
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class C { static int V; static int[] s; static boolean[][] adjMat; static boolean color(int u...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
fdbe11b22360a64ccaa3f081ed20b8d3
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.NoSuchElementException; import java.util.*; public class Main { int N,M; int[] kind; boolean[][] connect; public void solve(){ N = nextInt(); M = nextInt(); connect = new boolean[N][N]; for(int i = 0;i <...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
5f3dbd61eb49f38086752b3774e3874c
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.*; import java.util.*; public class Main { private final static InputReader ir = new InputReader(System.in); private final static PrintWriter ow = new PrintWriter(System.out); static int n; static char[] ans; static ArrayList<LinkedList<Integer>> graph; static void dfs(boolean[...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
5513b182016a0eda27e7244bdf2a24ff
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.IOException; import java.util.HashSet; import java.util.InputMismatchException; public class GraphAndString { public static void main(String[] args) { FasterScanner sc = new FasterScanner(); int N = sc.nextInt(); int M = sc.nextInt(); IntSet[] G = new IntSet...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
a6b8b40d6baf1d3346007f3f3e398625
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.util.Collection; import java.util.Collections; import java.util.HashSet; import java.util.Scanner; import java.util.Set; public class GraphString { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); ...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
dc9cd9a448540d1c9c718f8724208b45
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.IOException; import java.util.*; public class Main { public static void main(String[] args) throws IOException { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); boolean[][] g = new boolean[n][n]; for (int i = 0; i < n; ++i) g[...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
31cc32db2a989266a76631ca37c18a54
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.lang.String; import java.util.Arrays; import java.util.Scanner; import java.util.Comparator; public class C { public static void main(String[] args) { // TODO Auto-generated method s...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
03d29d5b36f2536335cc443efbb67514
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.lang.*; public class Third{ static long mod=1000000007; static boolean v[]=new boolean[10]; //For marking nodes as visited during DFS static int c=0; //No of connected components in graph static...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
a3e54b08631a307a2f9a23ea88e0d90d
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
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.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcept...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
671e2b81e16faa3031ec975db4820b5f
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.util.ArrayList; import java.util.Arrays; import java.util.Scanner; public class graphAndString { public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan=new Scanner(System.in); int v=scan.nextInt(); apoint[] ps=new apoint[v]; for(int i=0;i<v;i++){ ps[i]=new ...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
8c28d062f14f35475129ac16bcb9112b
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.awt.Point; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; public class C624 { /** * @param args * @throws IOException */ pub...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
66251a0af5d2ee9d0081862179e8d099
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import static java.lang.Math.*; import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.Double.parseDouble; import static java.lang.String.*; public class Main { static List<Integer> [] adj; st...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
adb76bc717861705b8d8e6ef520cded4
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.*; import java.util.*; public class Send { private static InputReader in; private static PrintWriter out; private static int B_COUNT = 0; public static void main(String[] args) { in = new InputReader(System.in); out = new PrintWriter(System.out, true); int n = ...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
bcf58da637f3768a5d004ce69eee8632
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayDeque; import java.util.Queue; public class ProblemC { BufferedReader rd; ProblemC() throws IOException { rd = new BufferedReader(new InputStreamReader(System.in)); compute(); ...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
817c210dfde7cbfb405c9ffcd40937c3
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
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.util.Set; import java.util.InputMismatchException; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; ...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
62682fa7122f9a66c84f320e07415c54
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
//package com.codeforces.competitions.year2016.jantomarch.aimtechrounddiv2; import java.io.*; import java.util.*; public final class TaskC { static int n, e; static boolean[][] adj; static char[] set; static int[] degree; static List<Integer>[] list; static InputReader in; static OutputWriter out; ...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
a9efc99cfed261165444c9503fa8b2fa
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
/** * * @author sarthak */ import java.util.*; import java.math.*; import java.io.*; public class aimtech_C { static int[] vis; static int c=1; static ArrayList<Integer> e[]; static ArrayList<Character> ne[]; static class FastScanner { BufferedReader br; StringTokenizer st; ...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
57b1c7c23d5c4e0abc8715855372312a
train_001.jsonl
1454605500
One day student Vasya was sitting on a lecture and mentioned a string s1s2... sn, consisting of letters "a", "b" and "c" that was written on his desk. As the lecture was boring, Vasya decided to complete the picture by composing a graph G with the following properties: G has exactly n vertices, numbered from 1 to n. ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Map; public class codef { public static void main(String[] args) throws IOException { BufferedReader B = new BufferedReader(new InputStreamReader(System.in)); String[] s = B.readLine().sp...
Java
["2 1\n1 2", "4 3\n1 2\n1 3\n1 4"]
2 seconds
["Yes\naa", "No"]
NoteIn the first sample you are given a graph made of two vertices with an edge between them. So, these vertices can correspond to both the same and adjacent letters. Any of the following strings "aa", "ab", "ba", "bb", "bc", "cb", "cc" meets the graph's conditions. In the second sample the first vertex is connected to...
Java 8
standard input
[ "constructive algorithms", "dfs and similar", "graphs" ]
e71640f715f353e49745eac5f72e682a
The first line of the input contains two integers n and m  — the number of vertices and edges in the graph found by Petya, respectively. Each of the next m lines contains two integers ui and vi (1 ≤ ui, vi ≤ n, ui ≠ vi) — the edges of the graph G. It is guaranteed, that there are no multiple edges, that is any pair of ...
1,800
In the first line print "Yes" (without the quotes), if the string s Petya is interested in really exists and "No" (without the quotes) otherwise. If the string s exists, then print it on the second line of the output. The length of s must be exactly n, it must consist of only letters "a", "b" and "c" only, and the grap...
standard output
PASSED
06eea6b99473b61ba92996c7c918918e
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
//package CodeForces.Round320; import java.util.*; /** * Created by Ilya Sergeev on 16.09.2015. */ public class Bnap { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); TreeMap<Integer,Integer[]> map = new TreeMap<>(new Comparator<Intege...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
c7fe325380b9f0dc893c4c95082eab3a
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.util.*; import java.awt.Point; import java.io.*; import java.math.BigInteger; public class CodeForces { FastScanner in; PrintWriter out; int searchMax(int mas[][], int n) { int max = 0; for (int i = 1; i < n; i++) for (int j = 0; j < i; j++) max = M...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
f735e3da7df8b99a1c26030e3e55cb54
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * User: dmitry */ public class Main { public static InputStream is = System.in; public static BufferedReader br = new BufferedR...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
c3ee5cdb601e3510edda68160f5f8d5c
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; public class Tablecity { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); Queue<StrengthWrapper> queue = new PriorityQueue<StrengthWrapper>(); ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
d0bc4a6672ed75aff8d2284e80daa7b1
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.awt.Point; import java.io.IOException; import java.io.InputStream; public class B579 { public static void main(String[] args) throws IOException { InputReader reader = new InputReader(System.in); int N = 2*reader.readInt(); Point[] data = new Point[1000001]; for (int ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
14f8ed662aae4b450cd8aa0dedf342e9
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * * @author jairneto */ public class p1 { private static InputReader ir; private static PrintWriter out; private st...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
7f670ac2b2c81ce004ef2efa5ffb2782
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.math.BigInteger; import java.util.ArrayList; import ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
08c8b7ac48ee5a759680af72ecbfcf7b
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Arrays; public class Main { class Node implements Comparable { int value; int l,r; public Node(int value,int l,int r) { ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
4a05cac5a0ccce6851360e220f9529a7
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.*; import java.util.*; public final class finding_team_members { static Scanner sc=new Scanner(System.in); static PrintWriter out=new PrintWriter(System.out); static int maxn=10001000; public static void main(String args[]) throws Exception { int n=sc.nextInt(),k=0; Pair[] a=new Pair[maxn]; ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
a09f6421779dfcb1f2cecbc9989b76e8
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; import java.util.TreeMap; /** * Created by pallavi.v on 10/9/2015. */ public class B579 { static int n; public static void main(String[] args) throws IOException { ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
f9a70aa6f5b102a807df5ba9998acbb0
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.BufferedReader; import java.io.Closeable; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import ja...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
0ae4e8373a3b6c75965cfab6d290ce6b
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class ProblemB { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.ou...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
8fc80322b25b22dc39b5d22ee433bb1f
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.util.Scanner; public class FindingTeamMembers { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); n*=2; int[][] person=new int[(int) (1e6+1)][2]; for(int i=1;i<=n;i++) { for(int j=1;j<i;j++) { int x=sc.nextInt(); person[x][0]=i; ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
e64fc28389ddb50c57a778b9ea7a34c6
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.Scanner; /** * Created by root on 25.09.15. */ public class MyClass { static int[][] arr; static int n; public static void main(String arg[]){ read(); searchPar(); } public static void findSearch(Integer[]...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
8e7c2b9c20a8b210db9698e3b1cc39b2
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.util.Arrays; import java.util.Comparator; import java.util.PriorityQueue; import java.util.Scanner; public class B_320 { static class A implements Comparable<A>{ int i,j,val; public A(int i, int j, int val){ this.i = i; this.j = j; this.val = va...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
38604e8b763790388418982bfde3d611
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.util.*; public class Main { static int n; static Pair p; static int[] mk=new int[1000]; static Queue<Pair> q=new PriorityQueue<Pair>(); static class Pair implements Comparable<Pair> { int x,y,z; Pair(int a,int b,int c) { x=a;y=b;z=c; } public int compareTo(Pair p) { return p.x-this.x; ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
3688343a7a3a53844ee8669aa981f17c
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.*; import java.util.*; /** * Created by Юля on 16.09.2015. */ public class SolverB578 { public static void main(String[] args) throws IOException { new SolverB578().run(); } BufferedReader br; PrintWriter pw; StringTokenizer tokenizer; public String nextToken() throw...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
9bb39502b04270e9afe7f6acd1d203c5
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.util.*; public class template { static LinkedList<strong> s = new LinkedList<strong>(); public static void main( String[] args ) { Scanner in = new Scanner( System.in ); int n = in.nextInt(); for ( int i = 2; i <= 2 * n; i++ ) for ( int j = 1; j < i; j++ ) ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
dc0c66c6f8938f64a9c4575d4d9ddd91
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Solver solver = new Solver(); solver.solve(); } } class Solver { Scanner stdin = new Scanner(System.in); final int MAXN = 800 + 5; int[][] a = new int[MAXN][MAXN]; int[] p = new int[MAXN]; int...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
899456af5207498564c42717f7017653
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; public class B320 { private class Node { ArrayList<Link> links; public Node(int n) { links = new Arr...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
c9f49874e4acdff7b2068d1351b1c110
train_001.jsonl
1442416500
There is a programing contest named SnakeUp, 2n people want to compete for it. In order to attend this contest, people need to form teams of exactly two people. You are given the strength of each possible combination of two people. All the values of the strengths are distinct.Every contestant hopes that he can find a t...
256 megabytes
import java.io.BufferedInputStream; import java.io.IOException; import java.io.PrintWriter; import java.util.Arrays; import java.util.InputMismatchException; public class Main { class MyScanner { private byte[] buf = new byte[1024]; private int curChar; private int numChars; BufferedInputStream ...
Java
["2\n6\n1 2\n3 4 5", "3\n487060\n3831 161856\n845957 794650 976977\n83847 50566 691206 498447\n698377 156232 59015 382455 626960"]
2 seconds
["2 1 4 3", "6 5 4 3 2 1"]
NoteIn the first sample, contestant 1 and 2 will be teammates and so do contestant 3 and 4, so the teammate of contestant 1, 2, 3, 4 will be 2, 1, 4, 3 respectively.
Java 7
standard input
[ "implementation", "sortings", "brute force" ]
8051385dab9d7286f54fd332c64e836e
There are 2n lines in the input. The first line contains an integer n (1 ≤ n ≤ 400) — the number of teams to be formed. The i-th line (i &gt; 1) contains i - 1 numbers ai1, ai2, ... , ai(i - 1). Here aij (1 ≤ aij ≤ 106, all aij are distinct) denotes the strength of a team consisting of person i and person j (people ar...
1,300
Output a line containing 2n numbers. The i-th number should represent the number of teammate of i-th person.
standard output
PASSED
b1454b8b835166f235ecfccc727481b1
train_001.jsonl
1475494500
There are n cities and m two-way roads in Berland, each road connects two cities. It is known that there is no more than one road connecting each pair of cities, and there is no road which connects the city with itself. It is possible that there is no way to get from one city to some other city using only these roads.T...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class E { static int deg[]; static int in[]; static int out[]; static boolean adjMat[][];; public static void main(String[] args) { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while(T-->0) { int n = sc.nextInt(); int ...
Java
["2\n5 5\n2 1\n4 5\n2 3\n1 3\n3 5\n7 2\n3 7\n4 2"]
2 seconds
["3\n1 3\n3 5\n5 4\n3 2\n2 1\n3\n2 4\n3 7"]
null
Java 11
standard input
[ "greedy", "graphs", "constructive algorithms", "flows", "dfs and similar" ]
4f2c2d67c1a84bf449959b06789bb3a7
The first line contains a positive integer t (1 ≤ t ≤ 200) — the number of testsets in the input. Each of the testsets is given in the following way. The first line contains two integers n and m (1 ≤ n ≤ 200, 0 ≤ m ≤ n·(n - 1) / 2) — the number of cities and the number of roads in Berland. The next m lines contain the...
2,200
For each testset print the maximum number of such cities that the number of roads that begins in the city, is equal to the number of roads that ends in it. In the next m lines print oriented roads. First print the number of the city where the road begins and then the number of the city where the road ends. If there are...
standard output
PASSED
fb308c2732c21fe14fd722548558e790
train_001.jsonl
1562339100
You are given $$$n$$$ numbers $$$a_1, a_2, \ldots, a_n$$$. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?For example, for the array $$$[1, 4, 5, 6, 7, 8]$$$, the arrangement on the left is valid, while arrangement on the right is not, as $$$5\g...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.BigInteger; public class Codechef { public static void main (String[] args) throws java.lang.Exception { InputReader in = new InputReader(System.in); int N=in.ni(); ArrayList<Integer> a = new ArrayList<Integer>(); for (int ...
Java
["3\n2 4 3", "5\n1 2 3 4 4", "3\n13 8 5", "4\n1 10 100 1000"]
1 second
["YES\n4 2 3", "YES\n4 4 2 1 3", "NO", "NO"]
NoteOne of the possible arrangements is shown in the first example: $$$4&lt; 2 + 3$$$;$$$2 &lt; 4 + 3$$$;$$$3&lt; 4 + 2$$$.One of the possible arrangements is shown in the second example.No matter how we arrange $$$13, 8, 5$$$ in a circle in the third example, $$$13$$$ will have $$$8$$$ and $$$5$$$ as neighbors, but $$...
Java 8
standard input
[ "sortings", "greedy", "math" ]
a5ee97e99ecfe4b72c0642546746842a
The first line contains a single integer $$$n$$$ ($$$3\le n \le 10^5$$$) — the number of numbers. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \le 10^9$$$) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
1,100
If there is no solution, output "NO" in the first line. If there is a solution, output "YES" in the first line. In the second line output $$$n$$$ numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are mul...
standard output
PASSED
bee7277715c6007f9674af1ed4ea244c
train_001.jsonl
1562339100
You are given $$$n$$$ numbers $$$a_1, a_2, \ldots, a_n$$$. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?For example, for the array $$$[1, 4, 5, 6, 7, 8]$$$, the arrangement on the left is valid, while arrangement on the right is not, as $$$5\g...
256 megabytes
import java.util.*; public class Temppp { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Scanner sc = new Scanner(System.in); int n = sc.nextInt(); long[] arr = new long[n]; for(int...
Java
["3\n2 4 3", "5\n1 2 3 4 4", "3\n13 8 5", "4\n1 10 100 1000"]
1 second
["YES\n4 2 3", "YES\n4 4 2 1 3", "NO", "NO"]
NoteOne of the possible arrangements is shown in the first example: $$$4&lt; 2 + 3$$$;$$$2 &lt; 4 + 3$$$;$$$3&lt; 4 + 2$$$.One of the possible arrangements is shown in the second example.No matter how we arrange $$$13, 8, 5$$$ in a circle in the third example, $$$13$$$ will have $$$8$$$ and $$$5$$$ as neighbors, but $$...
Java 8
standard input
[ "sortings", "greedy", "math" ]
a5ee97e99ecfe4b72c0642546746842a
The first line contains a single integer $$$n$$$ ($$$3\le n \le 10^5$$$) — the number of numbers. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \le 10^9$$$) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
1,100
If there is no solution, output "NO" in the first line. If there is a solution, output "YES" in the first line. In the second line output $$$n$$$ numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are mul...
standard output
PASSED
92b4716fe5c9733cbd82d48976075d33
train_001.jsonl
1562339100
You are given $$$n$$$ numbers $$$a_1, a_2, \ldots, a_n$$$. Is it possible to arrange them in a circle in such a way that every number is strictly less than the sum of its neighbors?For example, for the array $$$[1, 4, 5, 6, 7, 8]$$$, the arrangement on the left is valid, while arrangement on the right is not, as $$$5\g...
256 megabytes
import java.util.*; import java.io.*; public class NumberCircle { private static void check(long[] array){ for (int i = 0; i < array.length; i++){ long current = array[i]; if (i == 0){ if (current >= (array[array.length - 1] + array[1])){ System.o...
Java
["3\n2 4 3", "5\n1 2 3 4 4", "3\n13 8 5", "4\n1 10 100 1000"]
1 second
["YES\n4 2 3", "YES\n4 4 2 1 3", "NO", "NO"]
NoteOne of the possible arrangements is shown in the first example: $$$4&lt; 2 + 3$$$;$$$2 &lt; 4 + 3$$$;$$$3&lt; 4 + 2$$$.One of the possible arrangements is shown in the second example.No matter how we arrange $$$13, 8, 5$$$ in a circle in the third example, $$$13$$$ will have $$$8$$$ and $$$5$$$ as neighbors, but $$...
Java 8
standard input
[ "sortings", "greedy", "math" ]
a5ee97e99ecfe4b72c0642546746842a
The first line contains a single integer $$$n$$$ ($$$3\le n \le 10^5$$$) — the number of numbers. The second line contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \le 10^9$$$) — the numbers. The given numbers are not necessarily distinct (i.e. duplicates are allowed).
1,100
If there is no solution, output "NO" in the first line. If there is a solution, output "YES" in the first line. In the second line output $$$n$$$ numbers — elements of the array in the order they will stay in the circle. The first and the last element you output are considered neighbors in the circle. If there are mul...
standard output
PASSED
b2bebfa3ef188fe4d7e55e868c22ed1a
train_001.jsonl
1390231800
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi...
256 megabytes
import java.util.* ; import java.io.* ; public class Problems { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintWriter(outputStr...
Java
["4\n0 0 1 0", "5\n1 0 1 0 1"]
1 second
["1", "3"]
NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost.
Java 8
standard input
[ "greedy" ]
1a3b22a5a8e70505e987d3e7f97e7883
The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.
1,600
Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
6b56831a9eee769557d48e45f6ab5151
train_001.jsonl
1390231800
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; import java.math.*; import java.util.concurrent.*; public class Main { //--------------------------------------------------------------------------- public static void main(String[] args) throws Exception { InputReader in = new InputReader(Syst...
Java
["4\n0 0 1 0", "5\n1 0 1 0 1"]
1 second
["1", "3"]
NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost.
Java 8
standard input
[ "greedy" ]
1a3b22a5a8e70505e987d3e7f97e7883
The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.
1,600
Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
096d0579f97fa311f975b19104cdbe2f
train_001.jsonl
1390231800
Iahub helps his grandfather at the farm. Today he must milk the cows. There are n cows sitting in a row, numbered from 1 to n from left to right. Each cow is either facing to the left or facing to the right. When Iahub milks a cow, all the cows that see the current cow get scared and lose one unit of the quantity of mi...
256 megabytes
import java.awt.Point; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.io.IOException; import java.util.Scanner; public class Other { static int n; static int[] arr; public static void main(String[] args) throws NumberFormatException, IOExce...
Java
["4\n0 0 1 0", "5\n1 0 1 0 1"]
1 second
["1", "3"]
NoteIn the first sample Iahub milks the cows in the following order: cow 3, cow 4, cow 2, cow 1. When he milks cow 3, cow 4 loses 1 unit of milk. After that, no more milk is lost.
Java 8
standard input
[ "greedy" ]
1a3b22a5a8e70505e987d3e7f97e7883
The first line contains an integer n (1 ≤ n ≤ 200000). The second line contains n integers a1, a2, ..., an, where ai is 0 if the cow number i is facing left, and 1 if it is facing right.
1,600
Print a single integer, the minimum amount of lost milk. Please, do not write the %lld specifier to read or write 64-bit integers in С++. It is preferred to use the cin, cout streams or the %I64d specifier.
standard output
PASSED
3cc21fd96a6f5d3b42f3be5c05719953
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Main { static Scanner input=new Scanner(System.in); public static void main(String args[]) { int test=input.nextInt(); for(int t=0;t<test;t++) { int n=input.nextInt(); int s=input.nextInt(); int k...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
97efd25ff89f387a625fc26f6166c671
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class Div2A_614 { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); int[] ans=new int[t]; for (int i=0;i<t;i++) { int n=sc.nextInt(); int s=sc....
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
8109ad77cf955b0cf2fe1f9a1f808bc8
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import javax.swing.plaf.synth.SynthSeparatorUI; public class temp1 { public static void main(String[] args) throws IOException { Reader scn = new Reader(); // Scanner scn = new Scanner(System.in); int t = scn.nextInt(); z: while (t-...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
cdc8de32b3c74b3e8de77e4d623a0818
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
//package com.company; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.io.PrintWriter; public class Main { static PrintWriter out=new PrintWriter(new OutputStreamWriter(System.out)); static class FastReader { byte[] buf = new byte[2048]; ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
970afc358fbeaf2846757914c3fc93e0
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public final class Main { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t>0){ int n=sc.nextInt(); int s=sc.nextInt(...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
c7b04d6448eef046746776b82f74c2da
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.ArrayList; import java.util.List; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); sc.nextLine(); while (t > 0) { int n, s, k; n = sc.nextInt(); s = sc.nextInt(); k = sc.nextInt(); ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
8faa082daa0eb2d648d82985fbf1943e
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.io.*; public class Main { public static void main(String[] args) throws Exception{ Scanner sc = new Scanner(System.in); int tt = sc.nextInt(); while(tt-- > 0) { int n = sc.nextInt(); int s = sc.nextInt(); int k = sc.nextInt(); HashSet<Integer> set = new ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
fad40e8e9d7271ff2039eb2103df9808
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class CodeForces1 { public static void main (String[] args) { Scanner scan = new Scanner(System.in); int t = scan.nextInt(); for (int i = 0; i < t; i++) { int n = scan.nextInt(); int s = scan.nextInt(); int k = scan.n...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
1d83c495a7269cabbd734819351a3a1e
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.*; import java.util.stream.Collectors; public class SolutionA extends Thread { static class FastReader { BufferedReader br; StringTokenizer st; public F...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
76e39706ed12c6c6b12177ff44cfd1e6
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class Main{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int t=sc.nextInt(); int i; int j; for(i=0;i<t;i++){ long n=sc.nextInt(); long s=sc.nextInt(); int k=sc.nextInt(); int a[]=new int[k]; int check=0; int ind=-1; int ans=0; l...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
a4957b620faa91be8dfbc4872e93b683
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.lang.*; public class Hello { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i=0;i<t;i++) { int n = sc.nextInt(); int p = sc.nextInt(); int k = sc.nextI...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
2dca61cdd1e6d265868e7c67e9273947
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; //import java.io.BufferedReader; //import java.io.IOException; //import java.io.InputStreamReader; //import java.io.*; public class call { public static void main(String args[]) { // FastIO io = new FastIO(); // BufferedReader reader = // new BufferedReade...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
4c2759d5633e3d437d868221f48cbe1b
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class temp { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while(t-->0) { int minl = Integer.MAX_VALUE; int minu = Integer.MAX_VALUE; int n = sc.nextInt(); int s=sc.nextIn...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
598a1a04de9484e33a9dbb37f1753f21
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static PrintWriter out = new PrintWriter(System.out); static Reader in = new Reader(); public static void main(String[] args) throws IOException { //Scanner sc = new Scanner(); Main solver = new Main(); s...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
e1f5617cb8d44c51eee7d9d2e3c4efba
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; public class S { static BufferedReader reader; static StringTokenizer tokenizer; /** call this method to initialize reader for InputStream */ static void init(InputStream input) { reader = new BufferedReader( new InputStreamReader(...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
9fd28758f4edc605ea91d61eb7d9b464
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; public class noob { InputReader in; final long mod=1000000007; StringBuilder sb; public static void main(String[] args) throws java.lang.Exception { new noob().run(); } void run() throws Exception { in=new InputReader(System.in); sb =...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
59d8825d64cc21b2f26d6832db8e89cd
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Scanner; import java.util.TreeSet; /** * Built using CHelper plug-in * Actual solution is at the top */ public class Main { public static void main(String[] args) { InputStre...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
eeab2a1f3da473fa74ed09aa33a38145
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
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)); int t = Integer.parseInt(br.readLine()); while (t-- > 0) { String[] line = br.readLine().s...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
fc883a77f2a88a8e3eb40b4dc2e8e7c0
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.BigInteger; import java.text.DecimalFormat; import java.util.*; import java.text.NumberFormat; //import java.util.Arrays; import java.util.regex.Matcher; import java.util.regex.Pat...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
c7c983667a1f106810d3d326ebd54c7a
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashSet; import java.util.StringTokenizer; public class A{ static int max = (int)1e9; public static void main(String[] args) throws Exception{ ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
0e8b9362b1036482f92ff0cdab807cfb
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
//normal import java.util.*; import java.lang.*; import java.io.*; // String Tokenizer public class Main { public static void main(String[] args) { // code Scanner scn = new Scanner(System.in); // System.out.println("Hi"); int t = scn.nextInt(); while (t >...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
63f2788e24a48a8472c24149130c2791
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; import java.awt.geom.*; import static java.lang.Math.*; public class Solution implements Runnable { public void solve() throws Exception { int t=sc.nextInt(); long mod=(long)1e9+7; while(t-->0) { ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
7f9923b75f88261a7c5996d9feab3c05
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.util.HashSet; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.io.Writer; import java.io.OutputStreamWriter; import java.util.InputMismatchException; import java.io.IOExcep...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
af0f604e92a8fa3a1ed20808d2103605
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
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 Ri...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
ab12476af9e04a469d68b43076eb7403
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
//package pkg1293a; import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { long n=sc.nextLong(); long s=sc.nextLong(); int k=sc.nextInt(...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
22b467bddf7e03958b4138bcba13d33d
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t-->0) { int sum=0,num=0; int n=sc.nextInt(); int s=sc.nextInt(); int k=sc.nextInt(); ArrayList<Integer> x=new ArrayList<>(); for(int i=0;i<k;i++) { ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
144055ec7f416080c87b153d9f7c4d75
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t-- > 0) { int n = sc.nextInt(); int s = sc.nextInt(); ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
fd473f9ebc3968afddda2081ceff2eff
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.Scanner; public class Test { public static void main(String[] args) { Scanner input = new Scanner(System.in); double t = input.nextDouble(); int floors[]; for (int i = 0; i < t; i++) { double n = input.nextDouble(); double s = input.nextD...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
09b24104c9e4810afbd4c4eac4657ff6
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*;import java.io.*;import java.math.*; public class Main { public static void process()throws IOException { int n=ni(),s=ni(),k=ni(); HashSet<Integer> set = new HashSet<Integer>(); for(int i=1;i<=k;i++) set.add(ni()); for(int i=0;i<=10001;i++){ int lst=Math.min...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
f568ee2aabd92d23fec1b2ed42412875
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; import java.lang.*; import static java.lang.Math.*; public class Cf131 implements Runnable { static class InputReader { private InputStream stream; private byte[] buf = new byte[1024]; private int curChar; private...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
1951cb93d11a525bc6e5e003d21d6cdb
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; public class CF1293A extends PrintWriter { CF1293A() { super(System.out); } Scanner sc = new Scanner(System.in); public static void main(String[] $) { CF1293A o = new CF1293A(); o.main(); o.flush(); } Random rand = new Random(); void sort(int[] aa, int n) { for (int i =...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
800ed74e6d99e7135856eb38e94bbbb9
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class ar { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() { br = new BufferedReader(new InputStreamReader(System.in)); ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
4fb063799a6499266cbd1b1c38dbe134
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; /** * Only By Abhi_Valani */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in; OutputStream outputStream = System.out; InputReader in = new InputReader(inputStream); PrintWriter out = new PrintW...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
d2aec220ca539ce709aa1227bfca39a5
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
/*input 5 5 2 3 */ import java.util.*; import java.lang.*; import java.io.*; public class Main { static Scanner in = new Scanner(System.in); static int ans=Integer.MAX_VALUE; public static void solve() { int n=in.nextInt(),curr=in.nextInt(),k=in.nextInt(); ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
800562bca0ed063846aa7dc9df558ac1
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.Arrays; import java.util.Scanner; /** * * @author DELL */ public class Codechef { static int fun(int f,int u,int ar[],int n) { if(u<ar.length-1) { if(ar[u+1]==f+1&&f<n) { f= fun(f+1,u+1,ar,n); r...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
af6ef77dd7d8432573521a99deb0ca1e
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.util.*; public class Main{ public static void main(String[] args) throws Exception{ MScanner sc=new MScanner(System.in); PrintWriter pw=new PrintWriter(System.out); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(),s=sc.nextInt(),k=sc.nextInt(); HashSet<Integer>closed...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
a4fd50b72a5030b5c8a3e0d0c8c8966b
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; public class Main { static boolean binarySearch(Integer[] arr,int l,int r,int value) { int mid=(l+r)/2; if(l>=r && arr[l]!=value) { return false; } if(arr[mid]==value) { return true; } else if(value<arr[m...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
105c0bf402637cf03a294c1c33277ca6
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class test { public static void main(String[] args) { int test = fs.nextInt(); // int test = 1; for (int t = 0; t < test; t++) { int n = fs.nextInt(); int s = fs.nextInt(); int k = fs.nextInt(); ArrayList<Integer> al = new ArrayList<In...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
ef872d759eeda30b32d6c088a0d0509d
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; import javax.swing.plaf.synth.SynthSeparatorUI; public class temp1 { public static void main(String[] args) throws IOException { Reader scn = new Reader(); // Scanner scn = new Scanner(System.in); int t = scn.nextInt(); z: while (t-- != ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
dc96496d18067a75bc1da474108d084a
train_001.jsonl
1579440900
Sakuzyo - ImprintingA.R.C. Markland-N is a tall building with $$$n$$$ floors numbered from $$$1$$$ to $$$n$$$. Between each two adjacent floors in the building, there is a staircase connecting them.It's lunchtime for our sensei Colin "ConneR" Neumann Jr, and he's planning for a location to enjoy his meal.ConneR's offic...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); while(t!=0){ int n=sc.nextInt(); ...
Java
["5\n5 2 3\n1 2 3\n4 3 3\n4 1 2\n10 2 6\n1 2 3 4 5 7\n2 1 1\n2\n100 76 8\n76 75 36 67 41 74 10 77"]
1 second
["2\n0\n4\n0\n2"]
NoteIn the first example test case, the nearest floor with an open restaurant would be the floor $$$4$$$.In the second example test case, the floor with ConneR's office still has an open restaurant, so Sensei won't have to go anywhere.In the third example test case, the closest open restaurant is on the $$$6$$$-th floo...
Java 11
standard input
[ "binary search", "implementation", "brute force" ]
faae9c0868b92b2355947c9adcaefb43
The first line contains one integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases in the test. Then the descriptions of $$$t$$$ test cases follow. The first line of a test case contains three integers $$$n$$$, $$$s$$$ and $$$k$$$ ($$$2 \le n \le 10^9$$$, $$$1 \le s \le n$$$, $$$1 \le k \le \min(n-1, 1000)...
1,100
For each test case print a single integer — the minimum number of staircases required for ConneR to walk from the floor $$$s$$$ to a floor with an open restaurant.
standard output
PASSED
351ca31c8e2a6d690522d58c494aaeff
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
//package codeforces; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; 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.StringTokenizer; ...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≤ ri ≤ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers — the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
9cbcf4cd314c836b87051d19d6c64d07
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
//package codeforces; import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; 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.HashMap; import j...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≤ ri ≤ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers — the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
d4a8fc958fa5f95bd857e36340fd36f7
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.BufferedReader; 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.StringTokenizer; import java.util.TreeMap; public class D { static MultiSet[] set; static Str...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≤ ri ≤ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers — the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
797eb05a145266e7a3db53cb7c0b89b8
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.BufferedReader; 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.HashMap; import java.util.StringTokenizer; public class D { static Mu...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≤ ri ≤ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers — the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
851b9d7bec7703224d8a091697b9338a
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.*; import java.math.*; import java.util.*; public class CODEFORCES { private InputStream is; private PrintWriter out; int n; ArrayList<Integer> a[], level[]; int depth[], st[], et[], rev[]; int len = -1; String b[]; void dfs(int u, int p) { st[u] = ++len; rev[len] = u; level[depth[u]].a...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≤ ri ≤ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers — the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output
PASSED
defc9cd377e2519280dcfaba7122b1b6
train_001.jsonl
1353511800
Polycarpus got hold of a family tree. The found tree describes the family relations of n people, numbered from 1 to n. Every person in this tree has at most one direct ancestor. Also, each person in the tree has a name, the names are not necessarily unique.We call the man with a number a a 1-ancestor of the man with a ...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.HashMap; import java.util.StringTokenizer; public class Main { static ArrayList<Integer> adjList[], queries[]; static String[] name; static int[] size, level, tin, tout, vertex, biggest, queryLevels, ans; static HashMap<String, Integer> map...
Java
["6\npasha 0\ngerald 1\ngerald 1\nvalera 2\nigor 3\nolesya 1\n5\n1 1\n1 2\n1 3\n3 1\n6 1", "6\nvalera 0\nvalera 1\nvalera 1\ngerald 0\nvalera 4\nkolya 4\n7\n1 1\n1 2\n2 1\n2 2\n4 1\n5 1\n6 1"]
3 seconds
["2\n2\n0\n1\n0", "1\n0\n0\n0\n2\n0\n0"]
null
Java 8
standard input
[ "dp", "sortings", "data structures", "binary search", "dfs and similar" ]
e29842d75d7061ed2b4fca6c8488d0e4
The first line of the input contains a single integer n (1 ≤ n ≤ 105) — the number of people in the tree. Next n lines contain the description of people in the tree. The i-th line contains space-separated string si and integer ri (0 ≤ ri ≤ n), where si is the name of the man with a number i, and ri is either the number...
2,400
Print m whitespace-separated integers — the answers to Polycarpus's records. Print the answers to the records in the order, in which the records occur in the input.
standard output