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 | cb7ae2d249776f9381d8eb0cc30eb9d6 | train_002.jsonl | 1295626200 | According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can check ... | 256 megabytes | import java.io.*;
import java.util.Scanner;
public class Main
{
public static void main(String args[]) throws Exception
{
Solution sol = new Solution();
sol.Run();
}
static public class Solution
{
@SuppressWarnings("unused")
private Scanner scanner;
void solve(BufferedReader input, PrintStream out... | Java | ["5\n18\nVODKA\nCOKE\n19\n17"] | 2 seconds | ["2"] | NoteIn the sample test the second and fifth clients should be checked. | Java 6 | standard input | [
"implementation"
] | 4b7b0fba7b0af78c3956c34c29785e7c | The first line contains an integer n (1 ≤ n ≤ 100) which is the number of the bar's clients. Then follow n lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input data does no... | 1,000 | Print a single number which is the number of people Vasya should check to guarantee the law enforcement. | standard output | |
PASSED | 84bcc59b44fa09971d8c1ecb5a347200 | train_002.jsonl | 1295626200 | According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can check ... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.StreamTokenizer;
import java.util.ArrayList;
import java.util.HashSet;
public class Main {
private static StreamTokenizer in;
private static PrintWriter out;
private static BufferedReader inB;
... | Java | ["5\n18\nVODKA\nCOKE\n19\n17"] | 2 seconds | ["2"] | NoteIn the sample test the second and fifth clients should be checked. | Java 6 | standard input | [
"implementation"
] | 4b7b0fba7b0af78c3956c34c29785e7c | The first line contains an integer n (1 ≤ n ≤ 100) which is the number of the bar's clients. Then follow n lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input data does no... | 1,000 | Print a single number which is the number of people Vasya should check to guarantee the law enforcement. | standard output | |
PASSED | 3319bb8ef5d698c8a11cb32c0816c1c6 | train_002.jsonl | 1295626200 | According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can check ... | 256 megabytes | import java.util.Scanner;
public class Bar {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String[] arStr = {"ABSINTH", "BEER", "BRANDY", "CHAMPAGNE", "GIN", "RUM", "SAKE", "TEQUILA", "VODKA", "WHISKEY", "WINE"};
int n = sc.nextInt();
int num, cont;
num = cont = 0;
boolean c... | Java | ["5\n18\nVODKA\nCOKE\n19\n17"] | 2 seconds | ["2"] | NoteIn the sample test the second and fifth clients should be checked. | Java 6 | standard input | [
"implementation"
] | 4b7b0fba7b0af78c3956c34c29785e7c | The first line contains an integer n (1 ≤ n ≤ 100) which is the number of the bar's clients. Then follow n lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input data does no... | 1,000 | Print a single number which is the number of people Vasya should check to guarantee the law enforcement. | standard output | |
PASSED | ff2de04156020b99bea4969fa2e0b8f8 | train_002.jsonl | 1295626200 | According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can check ... | 256 megabytes | import java.io.*;
import java.util.InputMismatchException;
import java.util.Scanner;
/**
* Created with IntelliJ IDEA.
* User: DOAN Minh Quy
* Date: 7/25/13
* Time: 12:56 PM
*/
public class Task56A {
public static void main(String[] args) {
new Task56A().run();
}
void run() {
Scanner ... | Java | ["5\n18\nVODKA\nCOKE\n19\n17"] | 2 seconds | ["2"] | NoteIn the sample test the second and fifth clients should be checked. | Java 6 | standard input | [
"implementation"
] | 4b7b0fba7b0af78c3956c34c29785e7c | The first line contains an integer n (1 ≤ n ≤ 100) which is the number of the bar's clients. Then follow n lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input data does no... | 1,000 | Print a single number which is the number of people Vasya should check to guarantee the law enforcement. | standard output | |
PASSED | 300c1867a0d91b775cf0ebd357a8f9a5 | train_002.jsonl | 1295626200 | According to Berland laws it is only allowed to sell alcohol to people not younger than 18 years. Vasya's job is to monitor the law's enforcement. Tonight he entered a bar and saw n people sitting there. For every one of them Vasya happened to determine either the age or the drink the person is having. Vasya can check ... | 256 megabytes | import java.io.*;
public class round52A {
public static void main(String[] args)throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
String [] alcohol = new String [] {"ABSINTH", "BEER", "BRANDY", "CHAMPAGNE"... | Java | ["5\n18\nVODKA\nCOKE\n19\n17"] | 2 seconds | ["2"] | NoteIn the sample test the second and fifth clients should be checked. | Java 6 | standard input | [
"implementation"
] | 4b7b0fba7b0af78c3956c34c29785e7c | The first line contains an integer n (1 ≤ n ≤ 100) which is the number of the bar's clients. Then follow n lines, each describing one visitor. A line either contains his age (an integer from 0 to 1000) or his drink (a string of capital Latin letters from 1 to 100 in length). It is guaranteed that the input data does no... | 1,000 | Print a single number which is the number of people Vasya should check to guarantee the law enforcement. | standard output | |
PASSED | 4af8af6c6136c027bd441e3ade4cf049 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
public class Codeforces
{
public static void main(String args[])throws Exception
{
BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb=new StringBuilder();
int t=Integer.parseInt(bu.readLine());
while(t--... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | dd432457c8f43005bbc44271bb21fef2 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
public class Codeforces
{
public static void main(String args[])throws Exception
{
BufferedReader bu=new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb=new StringBuilder();
int t=Integer.parseInt(bu.readLine());
while(t--... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 009c753c268d29177b10126cc3edc967 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
public class booksez2 {
public static void main(String[] args) {
Scanner iangay = new Scanner(System.in);
int tc = iangay.nextInt();
for (int i = 0; i < tc; i++) {
int kids = iangay.nextInt();
int[] books = new int[kids];
for (int j = 0... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 4f15933f22e08c588b91ff7305813f4d | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
public class booksez {
public static void main(String[] args) {
Scanner iangay = new Scanner(System.in);
int tc = iangay.nextInt();
for (int i = 0; i < tc; i++) {
int kids = iangay.nextInt();
int[] books = new int[kids];
for (int j = 0;... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | db3d76182e9854bf5a60687ee449dbbe | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | /*
//// ///// /// ////// // // //// // /// // // ///// // // //////
/ // // //// / // // // // // //// // // // // // /
/ // //// ///// / ////// // // // ///// // // // /// ////// /
/ // // // // / // // // // // // // // // // // // // /
///... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | caf0bcfcd55bd6fa6b7fe12a3517feba | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.StringTokenizer;
public class Solution {
public static void main(String args[]) th... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 971b79327ccb9344d121928653049a80 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class Main {
static BufferedReader input = new BufferedReader(
new InputStreamReader(System.in)
);
public static void main(String[] args) throws IOException {
s... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 7d2f077b187ca31bc0251c442a5e2f30 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | /* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
Scanner sc=new Sc... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 259d607dd06b5da9e627b31c5cc95df3 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
public class A
{
static int [] d , p;
static boolean [] vis ;
public static void main(String[] args) throws Exception
{
Scanner sc = new Scanner() ;
PrintWriter out = new PrintWriter(System.out) ;
int q = sc.nextInt() ;
while(q-->0... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 36019fa4df8e99f2cd49dd642537e601 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | //package hiougyf;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
public class Solution {
public static void main(String[] args){
Scanner sc =new Scanner(System.in);
int t=sc.nextInt();
while(t-->0) {
int n=sc.nextInt();
int a[]=new int[n+1];
for(int i=0;i<n;i++) a[i+1]=sc... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 480b042dc27e78e9d1d1002b5ab42422 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Scanner;
public class BookOwner {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
PrintWriter out = new PrintWriter(System.out);
int t = sc.nextInt();
while (t-- > 0) {
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 3ed523f08c36b09e9209d0242fd7b23e | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes |
import java.util.Scanner;
public class Solution1249B1 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int t = scanner.nextInt();
while (t-- > 0)
{
int n = scanner.nextInt();
int[] arr = new int[n];
for (int... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 029e3fab88a03d9b0d86bf14a1a70ffc | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.ArrayList;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
ArrayList<String> answer = new ArrayList<>();
Scanner scanner = new Scanner(System.in);
String requests = scanner.nextLine();
for (int i = 0; i<Integer.parseInt(request... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 7b1dc41ac1dd5208f42d799ccde6d34d | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
import java.io.*;
public class B{
static class FastScanner {
BufferedReader br;
StringTokenizer st;
FastScanner(InputStream stream) {
try {
br = new BufferedReader(new
InputStreamReader(stream));
} catch (Except... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 4628d20ff8a92921a0cca082189edad9 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
public class S {
public static long gcd(long a, long b)
{
if (b == 0)
return a;
return gcd(b, a % b);
}
public static void main(String args[]) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-- > 0) {
int n = s.nextInt();
int ... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | d28f3069a227fd119edfa56a247f0d90 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | // package com.company;
import java.util.*;
import java.io.*;
import java.lang.*;
/*
** @author jigar_nainuji
*/
public class Main{
public static void main(String args[]){
PrintWriter out=new PrintWriter(System.out);
InputReader in=new InputReader(System.in);
TASK s... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | e084ab36513d8f316b323aa683436db5 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
import java.io.*;
public class Solution{
public static void main(String[] args) throws Exception{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int t = Integer.parseInt(br.readLine().trim());
while(t-->0){
int n = Integer.parseI... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | be228a11f5de41a16c43f68b2408295b | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.Scanner;
public class pen {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int runs = scan.nextInt();
for(int i = 0;i<runs;i++){
int people = scan.nextInt();
int[] array = new int[people];
for(int x = 0;x<people;x++){
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 7a7c62ae06fcf555bf0cb73219a182f0 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | //package pkg1249b1;
import java.util.*;
public class Main
{
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
int q=sc.nextInt();
while(q-->0)
{
int n=sc.nextInt();
int array[]=new int[n+1];
for(int i=1;i<=n;i++)
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | bc3933919de7e44ffbf977acfadb21a4 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes |
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
/**
*
* @author Auby
*/
public class P2 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int queries = scanner.nextInt();
Set<Integer> studentsSkills;
for (int i = 0; i... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 1a66c544df8c15dfc478d3c8c75b301e | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
import java.lang.Math;
import java.lang.*;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 90fcc1f6fa086a27a626a6de94365c18 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
static PrintWriter out;
static class FastReader{
BufferedReader br;
StringTokenizer st;
public FastReader(){
br=new BufferedReade... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | a7bea746fddcddc4e832cb9ccc50c5d1 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int q = in.nextInt();
while (q-- > 0) {
int n = in.nextInt();
final int[] p = new int[n];
int[] now = new ... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 4bfb7b2cd5853d82798ba47bcf9529f9 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 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 in... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 77323a8f3ef1630fbfb8b265e910bd31 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
public class p11 {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int T = sc.nextInt();
sc.nextLine();
int ans[][] = new int[T][];
for (int test = 0; test < T; test++) {
int n = sc.nextInt();
sc.nextL... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 59dbca23a41d9025ae454638fab39b64 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 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 | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | dd473a9faee5902ad82bbc439d3d9214 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes |
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int tcase = in.nextInt();
while(tcase-->0){
int count = in.nextInt();
int flag=0;
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | fc26c2beeef4b73eb7d6cc63bc07f348 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.Scanner;
/**
*
* @author DELL
*/
public class Codechef {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int q=sc.nextInt();
for(int i=0;i<q;i++)
{
int n=sc.nextInt();
int ar[]=new int[n];
for(int j=0;j<n;j++)
ar[j]=sc.nextInt();
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | b16cf0f8acc030fa5e8aa55a8ceea491 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
for(int q=0;q<t;q++)
{
int n=sc.nextInt();
int arr[]=new int[n];
int ans[]=new int[n];
for(int i... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | d4ed1e5363049ad571b83e509b62ec63 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes |
import java.util.Scanner;
import java.util.Arrays;
public class Main {
public static void main(String [] args) {
Scanner in = new Scanner(System.in);
int q = in.nextInt();
int [][] res = new int[q][];
for (int i = 0; i < q; ++i) {
int N = in.nextInt();
int[] test = new int[N];
for (int j = 0; j < N; ... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | a6e361fd7874124aa55c20ccd556a543 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes |
import java.util.*;
public class test {
private static final Scanner sc = new Scanner(System.in);
public static void main(String[] args) {
int t = sc.nextInt();
while (t > 0) {
int n=sc.nextInt();
int ar[]=new int[n+1];
ar[0]=0;
for(int i=1;i<=n;i++)
ar[i]=sc.nextInt();
int ans[]=new int[n... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | b9bc16f1fe3132c31a9689255010f9d3 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
public class Main {
static class Reader {
final private int BUFFER_SIZE = 1 << 16;
private DataInputStream din;
private byte[] buffer;
private int bufferPointer, bytesRead... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | a49934e7c2143a08afbf1bae09068099 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | /**
* @author egaeus
* @mail sebegaeusprogram@gmail.com
* @veredict Accepted
* @url <https://codeforces.com/problemset/problem/1249/B2>
* @category math
* @date 22/10/2019
**/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.StringTokenizer;
import j... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | fcb6a5d18a3c43c0439421596d0615e2 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.StringTokenizer;
public class BooksExchange {
static long MOD = 1_000_000_007;
static long pow(long x, long y, long mod) {
long res = 1;
x = x % mod;
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | ded53ebc77c5b73e3d9bd49ccc8941a7 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.Arrays;
public class BookExchange {
public static void main(String[] args) throws IOException {
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 13dedfb20682e6f20623f23cdb1b917c | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.Arrays;
import java.util.Scanner;
public class booksExchangeE {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
StringBuilder ans = new StringBuilder();
int q = sc.nextInt();
while (--q >= 0) {
int n = sc.nextInt(), a[] = new int[n];
for (int i = 0; i < n; ... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 58b738be2786cb7c87627a3f7e03c569 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.Scanner;
public class Ex2 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int nQueries = sc.nextInt();
for(int i=0; i<nQueries; i++) {
int nKids = sc.nextInt();
int kids[] = new int[nKids];
for(int j=0; j<nKids; j++) {
kids[j] = sc.nextInt();
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | b486931598fe9b312ba327e05291686f | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author ky112233
*/
public class Main {
public static void main(String[] args) {
InputStream ... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | da33f8cea286977f3738fcfcd02f36f6 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
public class BooksExchange {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
int q=sc.nextInt();
while(q--!=0) {
int n=sc.nextInt();int a[]=new int[n+1];for(int i=1;i<=n;i++)a[i]=sc.nextInt();
List<Integer> l=new ArrayList<>();
for(int i=1;i<=n;i++) {
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | fc84e9bb6fac8bed0a4cdeb8d3925b7a | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
// ▄▀▀▀▀▄ ▄▀▀▄ ▄▄ ▄▀▀▀▀▄ ▄▀▀▄ █ ▄▀▀█▄▄▄▄ ▄▀▀▄▀▀▀▄ ▄▀▀▀▀▄ ▄▀▀▀▀▄ ▄▀▀▀▀▄
// █ █ ▐ █ █ ▄▀ █ █ █ █ ▄▀ ▐ ▄▀ ▐ █ █ █ █ █ ▐ █ █ ▐ █ █ ▐
// ▀▄ ▐ █▄▄▄█ █ █ ▐ █▀▄ █▄▄▄▄▄ ▐ █▀▀█▀ ... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 5fe2c6534d81cd2547bf1da3eb787191 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class cf1249b1 {
static BufferedReader __in;
static PrintWriter __out;
static StringTokenizer input;
public static void main(String[] args) throws IOException {
__in = new BufferedRe... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | ab385e20ff4171499f9e5f6c5999127b | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | /* package whatever; // don't place package name! */
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is public. */
public class Ideone
{
public static void main (String[] args) throws java.lang.Exception
{
// your code goes here
BufferedRea... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | d6dc464c2844314bdca942d351f37d3b | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
import java.math.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t = in.nextInt();
for(int tt = 0; tt < t; tt++) {
int n = in.nextInt();
int[] ar = new int[n + 1];
for(int i = 1; i <= n; i++) ar[i] = in.nextInt();
for(in... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | b5c67f909ca4c31fdaf9500e74e29c62 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
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.IOException;
import java.util.Arr... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 5615d56296080a30a5116c139c0485a4 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int q = sc.nextInt();
while(q--!=0)
{
int n = sc.nextInt();
int a[] = new int[n];
for(int i=0;i<n;i++)
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | f72b0ece7b3a2e83b348b3f036af22e6 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int q = sc.nextInt();
while(q--!=0)
{
int n = sc.nextInt();
int a[] = new int[n];
for(int i=0;i<n;i++)
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | c05ff24a579c159846a6cc4109311f0e | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
public class MyClass {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int q = sc.nextInt();
while(q--!=0)
{
int n = sc.nextInt();
Graph g = new Graph(n);
for(int i=0;i<n;i+... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 23f5a1ba622655c0722ca98cd620980f | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | /* بِسْمِ اللَّهِ الرَّحْمَٰنِ الرَّحِيمِ */
//codeforces1249B
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static java.lang.Math.*;
import java.math.*;
public class Main{
static PrintWriter go = new PrintWriter(System.out);
public static void main(S... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 7e62a5ff58e4b6c5fa185ae35f3e4c50 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
public class B1
{
static int dfs(int u, int[] comp)
{
comp[u] = idx;
int cnt = 1;
for (int v : adj[u])
if (comp[v] == 0)
cnt += dfs(v, comp);
return cnt;
}
static ArrayList<Integer>[] adj;
static int idx;
static void solve(FastIO io)
{
int n = io.next... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 676fd7e05afff65cef6f898116869da4 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.StringTokenizer;
public class P_1249B1 {
static final FS sc = new FS();
static final PrintWriter pw = new PrintWriter(Sy... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | f4d300d312b70a0480dd14596d7c3933 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
import java.io.*;
public class B {
public static void main(String[] args) {
Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
int t = in.nextInt(); // Scanner has functions to read ints, longs, strings, chars, etc.
for (int i = 1; i <= t; ++i) {
int n = in.nex... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 6cb109cd07017f091cfe051a9d462734 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.BigInteger;
import java.math.BigDecimal;
import java.math.RoundingMode;
public class forces{
public static void main(String args[])throws IOException{
DataInputStream ins=new DataInputStream(System.in);
int t=Integer.parseInt(ins.readLine());
for(in... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 57624195143fe0593c0d84a1fc053052 | train_002.jsonl | 1571754900 | The only difference between easy and hard versions is constraints.There are $$$n$$$ kids, each of them is reading a unique book. At the end of any day, the $$$i$$$-th kid will give his book to the $$$p_i$$$-th kid (in case of $$$i = p_i$$$ the kid will give his book to himself). It is guaranteed that all values of $$$p... | 256 megabytes | import java.util.*;
public class solution{
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
int q = sc.nextInt();
ArrayList<Integer> a = new ArrayList<>();
while((q--)!=0){
int n = sc.nextInt();
int lol[] = new int[n+1];
... | Java | ["6\n5\n1 2 3 4 5\n3\n2 3 1\n6\n4 6 2 1 5 3\n1\n1\n4\n3 4 1 2\n5\n5 1 2 4 3"] | 1 second | ["1 1 1 1 1 \n3 3 3 \n2 3 3 2 1 3 \n1 \n2 2 2 2 \n4 4 4 1 4"] | null | Java 11 | standard input | [
"dsu",
"math"
] | 345e76bf67ae4342e850ab248211eb0b | The first line of the input contains one integer $$$q$$$ ($$$1 \le q \le 200$$$) — the number of queries. Then $$$q$$$ queries follow. The first line of the query contains one integer $$$n$$$ ($$$1 \le n \le 200$$$) — the number of kids in the query. The second line of the query contains $$$n$$$ integers $$$p_1, p_2, \... | 1,000 | For each query, print the answer on it: $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$, where $$$a_i$$$ is the number of the day the book of the $$$i$$$-th child is returned back to him for the first time in this query. | standard output | |
PASSED | 999ef0bc44f96d666e25d1e47e4c62f4 | train_002.jsonl | 1473584400 | You have recently fallen through a hole and, after several hours of unconsciousness, have realized you are in an underground city. On one of your regular, daily walks through the unknown, you have encountered two unusually looking skeletons called Sanz and P’pairus, who decided to accompany you and give you some puzzle... | 256 megabytes | //package bubblecup9f;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
public class G {
InputStream is;
PrintWriter out;
Strin... | Java | ["6\nabacba\n2\naba 6\nba 3\n3"] | 1 second | ["12"] | NoteFor example, with the string "abacba", words "aba" (6 points) and "ba" (3 points), and x = 3, you can get at most 12 points - the word "aba" appears once ("abacba"), while "ba" appears two times ("abacba"). Note that for x = 1, you could get at most 9 points, since you wouldn’t be able to count both "aba" and the f... | Java 8 | standard input | [
"flows"
] | dde8f30871a79db3581b7a44042d3aa0 | The first line of the input contains a single integer n (1 ≤ n ≤ 500) — the length of the crossword. The second line contains the crossword string. The third line contains a single integer m (1 ≤ m ≤ 100) — the number of given words, and next m lines contain description of words: each line will have a string representi... | 2,400 | Output single integer — maximum number of points you can get. | standard output | |
PASSED | 7b3dec7f75711de8faef28a5f38fd64f | train_002.jsonl | 1473584400 | You have recently fallen through a hole and, after several hours of unconsciousness, have realized you are in an underground city. On one of your regular, daily walks through the unknown, you have encountered two unusually looking skeletons called Sanz and P’pairus, who decided to accompany you and give you some puzzle... | 256 megabytes | //package bubblecup9f;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.InputMismatchException;
import java.util.List;
public class G {
InputStream is;
PrintWriter out;
Strin... | Java | ["6\nabacba\n2\naba 6\nba 3\n3"] | 1 second | ["12"] | NoteFor example, with the string "abacba", words "aba" (6 points) and "ba" (3 points), and x = 3, you can get at most 12 points - the word "aba" appears once ("abacba"), while "ba" appears two times ("abacba"). Note that for x = 1, you could get at most 9 points, since you wouldn’t be able to count both "aba" and the f... | Java 8 | standard input | [
"flows"
] | dde8f30871a79db3581b7a44042d3aa0 | The first line of the input contains a single integer n (1 ≤ n ≤ 500) — the length of the crossword. The second line contains the crossword string. The third line contains a single integer m (1 ≤ m ≤ 100) — the number of given words, and next m lines contain description of words: each line will have a string representi... | 2,400 | Output single integer — maximum number of points you can get. | standard output | |
PASSED | e3874e6921f63248dea6e3f134980511 | train_002.jsonl | 1428165300 | In this problem you will meet the simplified model of game Pudding Monsters.An important process in developing any game is creating levels. A game field in Pudding Monsters is an n × n rectangular grid, n of its cells contain monsters and some other cells contain game objects. The gameplay is about moving the monsters ... | 256 megabytes | //package zepto2015;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.InputMismatchException;
public class F {
InputStream is;
PrintWriter out;
String INPUT = "";
long ret = 0;
void solve()
{
i... | Java | ["5\n1 1\n4 3\n3 2\n2 4\n5 5"] | 2 seconds | ["10"] | null | Java 7 | standard input | [
"data structures",
"divide and conquer"
] | dfaeae0bd55670f562d34e3bf2a65522 | The first line contains a single integer n (1 ≤ n ≤ 3 × 105) — the size of the initial field. Next n lines contain the coordinates of the cells initially containing monsters. The i-th of the next lines contains two numbers ri, ci (1 ≤ ri, ci ≤ n) — the row number and the column number of the cell that initially contain... | 3,000 | Print the number of distinct square fragments of the original field that can form a new map. | standard output | |
PASSED | 0fdae867f95b5d4ee79a6877e6471548 | train_002.jsonl | 1473784500 | Sonya was unable to think of a story for this problem, so here comes the formal description.You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operation... | 256 megabytes | import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;
public class test1 {
pu... | Java | ["7\n2 1 5 11 5 9 11", "5\n5 4 3 2 1"] | 5 seconds | ["9", "12"] | NoteIn the first sample, the array is going to look as follows:2 3 5 6 7 9 11|2 - 2| + |1 - 3| + |5 - 5| + |11 - 6| + |5 - 7| + |9 - 9| + |11 - 11| = 9And for the second sample:1 2 3 4 5|5 - 1| + |4 - 2| + |3 - 3| + |2 - 4| + |1 - 5| = 12 | Java 11 | standard input | [
"dp",
"sortings"
] | 516ed4dbe4da9883c88888b134d6621f | The first line of the input contains a single integer n (1 ≤ n ≤ 3000) — the length of the array. Next line contains n integer ai (1 ≤ ai ≤ 109). | 2,300 | Print the minimum number of operation required to make the array strictly increasing. | standard output | |
PASSED | bd916867f218879aa646917eaa0d7b88 | train_002.jsonl | 1473784500 | Sonya was unable to think of a story for this problem, so here comes the formal description.You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operation... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class cf713c_2 {
public static void main(String[] args) throws IOException {
int n = ri(), a[] = ria(n);
long ans = 0;
PriorityQueue<Integer> pq = new PriorityQueue<>();
... | Java | ["7\n2 1 5 11 5 9 11", "5\n5 4 3 2 1"] | 5 seconds | ["9", "12"] | NoteIn the first sample, the array is going to look as follows:2 3 5 6 7 9 11|2 - 2| + |1 - 3| + |5 - 5| + |11 - 6| + |5 - 7| + |9 - 9| + |11 - 11| = 9And for the second sample:1 2 3 4 5|5 - 1| + |4 - 2| + |3 - 3| + |2 - 4| + |1 - 5| = 12 | Java 11 | standard input | [
"dp",
"sortings"
] | 516ed4dbe4da9883c88888b134d6621f | The first line of the input contains a single integer n (1 ≤ n ≤ 3000) — the length of the array. Next line contains n integer ai (1 ≤ ai ≤ 109). | 2,300 | Print the minimum number of operation required to make the array strictly increasing. | standard output | |
PASSED | aaf56b0480bab03d689d244531f0c209 | train_002.jsonl | 1473784500 | Sonya was unable to think of a story for this problem, so here comes the formal description.You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operation... | 256 megabytes | import java.io.*;
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
public class cf713c_3 {
public static void main(String[] args) throws IOException {
long n = ri(), a[] = rla((int) n), ans = 0;
PriorityQueue<Long> pq = new PriorityQueue<>();
for (int ... | Java | ["7\n2 1 5 11 5 9 11", "5\n5 4 3 2 1"] | 5 seconds | ["9", "12"] | NoteIn the first sample, the array is going to look as follows:2 3 5 6 7 9 11|2 - 2| + |1 - 3| + |5 - 5| + |11 - 6| + |5 - 7| + |9 - 9| + |11 - 11| = 9And for the second sample:1 2 3 4 5|5 - 1| + |4 - 2| + |3 - 3| + |2 - 4| + |1 - 5| = 12 | Java 11 | standard input | [
"dp",
"sortings"
] | 516ed4dbe4da9883c88888b134d6621f | The first line of the input contains a single integer n (1 ≤ n ≤ 3000) — the length of the array. Next line contains n integer ai (1 ≤ ai ≤ 109). | 2,300 | Print the minimum number of operation required to make the array strictly increasing. | standard output | |
PASSED | ef2a791763ccfa0474eb6e7db798ba5c | train_002.jsonl | 1473784500 | Sonya was unable to think of a story for this problem, so here comes the formal description.You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operation... | 256 megabytes | import java.util.*;
public class SlopeTrick {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
// int e=sc.nextInt();
// while(e-->0) {
int n=sc.nextInt();
int arr[]=new int[n];
for(int i=0;i<n;i++) {
arr[i]=sc.nextInt();
}
long ans=0;
// Arrays.sort(arr);
int t=arr[0];
... | Java | ["7\n2 1 5 11 5 9 11", "5\n5 4 3 2 1"] | 5 seconds | ["9", "12"] | NoteIn the first sample, the array is going to look as follows:2 3 5 6 7 9 11|2 - 2| + |1 - 3| + |5 - 5| + |11 - 6| + |5 - 7| + |9 - 9| + |11 - 11| = 9And for the second sample:1 2 3 4 5|5 - 1| + |4 - 2| + |3 - 3| + |2 - 4| + |1 - 5| = 12 | Java 11 | standard input | [
"dp",
"sortings"
] | 516ed4dbe4da9883c88888b134d6621f | The first line of the input contains a single integer n (1 ≤ n ≤ 3000) — the length of the array. Next line contains n integer ai (1 ≤ ai ≤ 109). | 2,300 | Print the minimum number of operation required to make the array strictly increasing. | standard output | |
PASSED | 7c18cbacf4daccbc1fa54144fd99afa0 | train_002.jsonl | 1473784500 | Sonya was unable to think of a story for this problem, so here comes the formal description.You are given the array containing n positive integers. At one turn you can pick any element and increase or decrease it by 1. The goal is the make the array strictly increasing by making the minimum possible number of operation... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.util.PriorityQueue;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.util.AbstractQueue;
import java.util.InputMis... | Java | ["7\n2 1 5 11 5 9 11", "5\n5 4 3 2 1"] | 5 seconds | ["9", "12"] | NoteIn the first sample, the array is going to look as follows:2 3 5 6 7 9 11|2 - 2| + |1 - 3| + |5 - 5| + |11 - 6| + |5 - 7| + |9 - 9| + |11 - 11| = 9And for the second sample:1 2 3 4 5|5 - 1| + |4 - 2| + |3 - 3| + |2 - 4| + |1 - 5| = 12 | Java 11 | standard input | [
"dp",
"sortings"
] | 516ed4dbe4da9883c88888b134d6621f | The first line of the input contains a single integer n (1 ≤ n ≤ 3000) — the length of the array. Next line contains n integer ai (1 ≤ ai ≤ 109). | 2,300 | Print the minimum number of operation required to make the array strictly increasing. | standard output | |
PASSED | c74524be17c7b038e2510720e50c16d8 | train_002.jsonl | 1326380700 | Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.He's got problems with... | 256 megabytes | import java.util.*;
public class cf142c {
static int n,m;
static byte[][][] memo;
static byte[][][] move;
static char[][] board;
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
n = in.nextInt();
m = in.nextInt();
memo = new byte[n][m][(1<<(2*m+1))];
move = new byte[n][m][(1... | Java | ["3 3", "5 6", "2 2"] | 3 seconds | ["1\nAAA\n.A.\n.A.", "4\nA..C..\nAAAC..\nABCCCD\n.B.DDD\nBBB..D", "0\n..\n.."] | null | Java 6 | standard input | [] | f29eba31c20246686b8427b7aeadd184 | The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9). | 2,300 | In the first line print the maximum number of turboplows that can be positioned in the warehouse. In each of the next n lines print m characters. Use "." (dot) to mark empty space and use successive capital Latin letters ("A" for the first turboplow, "B" for the second one and so on until you reach the number of turbop... | standard output | |
PASSED | 360738bf175074394f860d89ab42ce7a | train_002.jsonl | 1326380700 | Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.He's got problems with... | 256 megabytes | import java.io.*;
import java.util.*;
public class C {
int m, n, kq;
char[][] ans;
char[][] out;
char[][][] p = new char[4][3][3];
final public void solve() throws IOException {
m = nextInt();
n = nextInt();
ans = new char[m][n];
out = new char[m][n];
for... | Java | ["3 3", "5 6", "2 2"] | 3 seconds | ["1\nAAA\n.A.\n.A.", "4\nA..C..\nAAAC..\nABCCCD\n.B.DDD\nBBB..D", "0\n..\n.."] | null | Java 6 | standard input | [] | f29eba31c20246686b8427b7aeadd184 | The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9). | 2,300 | In the first line print the maximum number of turboplows that can be positioned in the warehouse. In each of the next n lines print m characters. Use "." (dot) to mark empty space and use successive capital Latin letters ("A" for the first turboplow, "B" for the second one and so on until you reach the number of turbop... | standard output | |
PASSED | 20ca24eab07b63ce587391b86287cf1c | train_002.jsonl | 1326380700 | Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.He's got problems with... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class Main implements Runnable{
FastScanner sc;
BufferedReader reader;
PrintWriter out;
int n;
int m;
int ans = 0;
int col = 0;
int iter = 0;
int[][] b;
int[][] a;
int[][] dx = {{-1,-1,-1, 1}, {-1, ... | Java | ["3 3", "5 6", "2 2"] | 3 seconds | ["1\nAAA\n.A.\n.A.", "4\nA..C..\nAAAC..\nABCCCD\n.B.DDD\nBBB..D", "0\n..\n.."] | null | Java 6 | standard input | [] | f29eba31c20246686b8427b7aeadd184 | The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9). | 2,300 | In the first line print the maximum number of turboplows that can be positioned in the warehouse. In each of the next n lines print m characters. Use "." (dot) to mark empty space and use successive capital Latin letters ("A" for the first turboplow, "B" for the second one and so on until you reach the number of turbop... | standard output | |
PASSED | 03d32ac202039cf42381a0b3e08d43ea | train_002.jsonl | 1326380700 | Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.He's got problems with... | 256 megabytes | import java.io.*;
import java.util.*;
import java.math.*;
public class Solution implements Runnable {
private BufferedReader in;
private PrintWriter out;
private StringTokenizer st;
private Random rnd;
/*String[][] vars = {{"###", ".#.", ".#."}, {"..#", "###", "..#"}, {... | Java | ["3 3", "5 6", "2 2"] | 3 seconds | ["1\nAAA\n.A.\n.A.", "4\nA..C..\nAAAC..\nABCCCD\n.B.DDD\nBBB..D", "0\n..\n.."] | null | Java 6 | standard input | [] | f29eba31c20246686b8427b7aeadd184 | The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9). | 2,300 | In the first line print the maximum number of turboplows that can be positioned in the warehouse. In each of the next n lines print m characters. Use "." (dot) to mark empty space and use successive capital Latin letters ("A" for the first turboplow, "B" for the second one and so on until you reach the number of turbop... | standard output | |
PASSED | c8fe9e1376036df4522b9806eff50cb1 | train_002.jsonl | 1326380700 | Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.He's got problems with... | 256 megabytes |
import java.util.*;
public class taskE {
public static void main(String[] args) {
new taskE().main();
}
Scanner s = new Scanner(System.in);
int bestfield[][] = null;
int bestres = 0;
int area = 0;
int[][] delta0 = {{0, 0}, {-1, 0}, {1, 0}, {0, -1}, {0, -2}};
int[][] delta1 = {... | Java | ["3 3", "5 6", "2 2"] | 3 seconds | ["1\nAAA\n.A.\n.A.", "4\nA..C..\nAAAC..\nABCCCD\n.B.DDD\nBBB..D", "0\n..\n.."] | null | Java 6 | standard input | [] | f29eba31c20246686b8427b7aeadd184 | The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9). | 2,300 | In the first line print the maximum number of turboplows that can be positioned in the warehouse. In each of the next n lines print m characters. Use "." (dot) to mark empty space and use successive capital Latin letters ("A" for the first turboplow, "B" for the second one and so on until you reach the number of turbop... | standard output | |
PASSED | 010093e64eac358bcafdd01790dfc809 | train_002.jsonl | 1326380700 | Autumn came late to the kingdom of Far Far Away. The harvest was exuberant and it is now time to get ready for the winter. As most people celebrate the Harvest festival, Simon the Caretaker tries to solve a very non-trivial task of how to find place for the agricultural equipment in the warehouse.He's got problems with... | 256 megabytes | //package Round102;
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public class HelpCaretakerGenerated {
public static int[][] dp;
public static String[][][] paths;
/**
* @param args
*/
public static v... | Java | ["3 3", "5 6", "2 2"] | 3 seconds | ["1\nAAA\n.A.\n.A.", "4\nA..C..\nAAAC..\nABCCCD\n.B.DDD\nBBB..D", "0\n..\n.."] | null | Java 6 | standard input | [] | f29eba31c20246686b8427b7aeadd184 | The only line contains two space-separated integers n and m — the sizes of the warehouse (1 ≤ n, m ≤ 9). | 2,300 | In the first line print the maximum number of turboplows that can be positioned in the warehouse. In each of the next n lines print m characters. Use "." (dot) to mark empty space and use successive capital Latin letters ("A" for the first turboplow, "B" for the second one and so on until you reach the number of turbop... | standard output | |
PASSED | eb4c8fd6c1952bc98eede119ad447fe4 | train_002.jsonl | 1363534200 | Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following: Add the integer xi to the first ai elements of the sequence. Append an integer ki to the end of the sequence. (And he... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
public class A {
public static int i(String s) { return Integer.parseInt(s); }
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
StringBuild... | Java | ["5\n2 1\n3\n2 3\n2 1\n3", "6\n2 1\n1 2 20\n2 2\n1 2 -3\n3\n3"] | 1.5 seconds | ["0.500000\n0.000000\n1.500000\n1.333333\n1.500000", "0.500000\n20.500000\n14.333333\n12.333333\n17.500000\n17.000000"] | NoteIn the second sample, the sequence becomes | Java 6 | standard input | [
"data structures",
"constructive algorithms",
"implementation"
] | d43d4fd6c1e2722da185f34d902ace97 | The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of operations. The next n lines describe the operations. Each line will start with an integer ti (1 ≤ ti ≤ 3), denoting the type of the operation (see above). If ti = 1, it will be followed by two integers ai, xi (|xi| ≤ 103; 1 ≤ ai). If ti = 2, it... | 1,600 | Output n lines each containing the average of the numbers in the sequence after the corresponding operation. The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6. | standard output | |
PASSED | 7e8ba32708fa35c25fa256a64fad5bbb | train_002.jsonl | 1363534200 | Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following: Add the integer xi to the first ai elements of the sequence. Append an integer ki to the end of the sequence. (And he... | 256 megabytes | import java.io.DataInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.text.DecimalFormat;
/**
*
* @author sukhdeep
*/
public class Case {
static class InputReader {
final private int B_SIZE = 1 << 16;
private DataInputS... | Java | ["5\n2 1\n3\n2 3\n2 1\n3", "6\n2 1\n1 2 20\n2 2\n1 2 -3\n3\n3"] | 1.5 seconds | ["0.500000\n0.000000\n1.500000\n1.333333\n1.500000", "0.500000\n20.500000\n14.333333\n12.333333\n17.500000\n17.000000"] | NoteIn the second sample, the sequence becomes | Java 6 | standard input | [
"data structures",
"constructive algorithms",
"implementation"
] | d43d4fd6c1e2722da185f34d902ace97 | The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of operations. The next n lines describe the operations. Each line will start with an integer ti (1 ≤ ti ≤ 3), denoting the type of the operation (see above). If ti = 1, it will be followed by two integers ai, xi (|xi| ≤ 103; 1 ≤ ai). If ti = 2, it... | 1,600 | Output n lines each containing the average of the numbers in the sequence after the corresponding operation. The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6. | standard output | |
PASSED | 83e5861df4bfcf7a93bd8ec15557b013 | train_002.jsonl | 1363534200 | Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following: Add the integer xi to the first ai elements of the sequence. Append an integer ki to the end of the sequence. (And he... | 256 megabytes | import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
public static void main(String[] args) throws IOException {
(new Main()).solve();
}
public Main() {
}
MyReader in = new MyReader();
PrintWriter out = new PrintWriter(System.out);
void solve() throws IOException {
// ... | Java | ["5\n2 1\n3\n2 3\n2 1\n3", "6\n2 1\n1 2 20\n2 2\n1 2 -3\n3\n3"] | 1.5 seconds | ["0.500000\n0.000000\n1.500000\n1.333333\n1.500000", "0.500000\n20.500000\n14.333333\n12.333333\n17.500000\n17.000000"] | NoteIn the second sample, the sequence becomes | Java 6 | standard input | [
"data structures",
"constructive algorithms",
"implementation"
] | d43d4fd6c1e2722da185f34d902ace97 | The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of operations. The next n lines describe the operations. Each line will start with an integer ti (1 ≤ ti ≤ 3), denoting the type of the operation (see above). If ti = 1, it will be followed by two integers ai, xi (|xi| ≤ 103; 1 ≤ ai). If ti = 2, it... | 1,600 | Output n lines each containing the average of the numbers in the sequence after the corresponding operation. The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6. | standard output | |
PASSED | 26b12f79a0cfd0362fb4598144a71a90 | train_002.jsonl | 1363534200 | Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following: Add the integer xi to the first ai elements of the sequence. Append an integer ki to the end of the sequence. (And he... | 256 megabytes | import java.util.*;
import java.io.*;
/*
This is an implementation of a recursive splaying algorithm.
It depends on "deep splay" to keep the tree balanced
preventing stack overflow on the splays, and guaranteeing O(log n)
worst case time. It's also totally functional. i.e. the trees are
persistent. It us... | Java | ["5\n2 1\n3\n2 3\n2 1\n3", "6\n2 1\n1 2 20\n2 2\n1 2 -3\n3\n3"] | 1.5 seconds | ["0.500000\n0.000000\n1.500000\n1.333333\n1.500000", "0.500000\n20.500000\n14.333333\n12.333333\n17.500000\n17.000000"] | NoteIn the second sample, the sequence becomes | Java 6 | standard input | [
"data structures",
"constructive algorithms",
"implementation"
] | d43d4fd6c1e2722da185f34d902ace97 | The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of operations. The next n lines describe the operations. Each line will start with an integer ti (1 ≤ ti ≤ 3), denoting the type of the operation (see above). If ti = 1, it will be followed by two integers ai, xi (|xi| ≤ 103; 1 ≤ ai). If ti = 2, it... | 1,600 | Output n lines each containing the average of the numbers in the sequence after the corresponding operation. The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6. | standard output | |
PASSED | 6fa1f2a0039b42c483f867e376aaeff4 | train_002.jsonl | 1363534200 | Bessie and the cows are playing with sequences and need your help. They start with a sequence, initially containing just the number 0, and perform n operations. Each operation is one of the following: Add the integer xi to the first ai elements of the sequence. Append an integer ki to the end of the sequence. (And he... | 256 megabytes | import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.StringTokenizer;
import java.util.Arrays;
public class c{
public static void main(String args[]) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
S... | Java | ["5\n2 1\n3\n2 3\n2 1\n3", "6\n2 1\n1 2 20\n2 2\n1 2 -3\n3\n3"] | 1.5 seconds | ["0.500000\n0.000000\n1.500000\n1.333333\n1.500000", "0.500000\n20.500000\n14.333333\n12.333333\n17.500000\n17.000000"] | NoteIn the second sample, the sequence becomes | Java 6 | standard input | [
"data structures",
"constructive algorithms",
"implementation"
] | d43d4fd6c1e2722da185f34d902ace97 | The first line contains a single integer n (1 ≤ n ≤ 2·105) — the number of operations. The next n lines describe the operations. Each line will start with an integer ti (1 ≤ ti ≤ 3), denoting the type of the operation (see above). If ti = 1, it will be followed by two integers ai, xi (|xi| ≤ 103; 1 ≤ ai). If ti = 2, it... | 1,600 | Output n lines each containing the average of the numbers in the sequence after the corresponding operation. The answer will be considered correct if its absolute or relative error doesn't exceed 10 - 6. | standard output | |
PASSED | 444ac43d39f8fab4f9e81c3bc296ac8d | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes | import java.io.*;
import java.util.*;
public class Main {
static Scanner sc = new Scanner(System.in);
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws Exception {
int t = sc.nextInt();
while(t-- > 0) {
int n = sc.nextInt(), x = sc.nextInt();
PriorityQue... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | 7119b121fa8d08ad6bd444e91ba07820 | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes | import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.*;
public class CrateTheTeams {
static class FastReader {
BufferedReader br;
StringTokenizer st;
public FastReader() {
br = new Buffer... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | 62282c01fb6a88adf2e8bd08d932b561 | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes | // package JPackage;
import java.util.*;
public class Main {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int t=in.nextInt();
while(t-->0)
{
int n=in.nextInt();
int x=in.nextInt();
int[] arr=new int[n];
List<Integer> al=new ArrayList<Integer>();
Stack<Integ... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | c313d0cee69547edd19b325a13649d2b | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes | import java.util.*;
import java.io.*;
public class teams {
public static void main(String[] args) throws java.io.IOException {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
long loops = input.nextLong();
for (long l = 0; l < loops; l++) {
long size = input.nextLong();
long mi... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | e2bb03690a77f0da17291f6883f372ea | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes | import java.util.*;
public class Question3{
static Scanner sc = new Scanner(System.in);
public static void main(String[] args){
int t = sc.nextInt();
while(t-->0){
solve();
}
}
public static void solve(){
int n = sc.nextInt();
int... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | f03688face607b7787c8595eade40747 | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 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 n=sc.nextInt();
int x=sc.nextInt();
Integer[] arr=new Integer[n];
... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | dd11b3b0bd2a2fa939fa77ef40288f42 | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main{
public static void main(String[] args) throws IOException{
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
int t = Integer.parseInt(reader.readLin... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | 61669c31fc8f86201ccf22c1021e1a79 | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main2 {
///////----------------input----------------//////
static BufferedReader br= new BufferedReader(new
InputStreamReader(System.in));
static BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
static StringTokenizer st;
st... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | 16c67d6c4a9f7c0069fcf3e4dda4b1c2 | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes | // package com.company.codeforces
import java.io.*;
import java.util.*;
public class Solution {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t=input.nextInt();
while (t-->0){
int n=input.nextInt();
int s=input.nextInt();
... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | f1589cf6c37a8d6d7c384cf736ec4b1f | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes | /*
-------------------------------------------------------------------
* @Name: 1380C Create The Teams
* @Author: Yanan
* @Create Time: 2020/7/14 21:26:18 (UTC+08:00)
* @Url: https://codeforces.com/contest/1380/problem/C
* @Description:
----------------------------------------------... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | 4e9e451174486fcbec9dfbb940c6b26d | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 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
*/
public class... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | 6c39ded5c6ad82d2bddf592817718e30 | train_002.jsonl | 1594565100 | There are $$$n$$$ programmers that you want to split into several non-empty teams. The skill of the $$$i$$$-th programmer is $$$a_i$$$. You want to assemble the maximum number of teams from them. There is a restriction for each team: the number of programmers in the team multiplied by the minimum skill among all progra... | 256 megabytes |
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.lang.reflect.Array;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;
import java.util.Objects;
import java.util.regex.Pa... | Java | ["3\n5 10\n7 11 2 9 5\n4 8\n2 4 2 3\n4 11\n1 3 3 7"] | 2 seconds | ["2\n1\n0"] | null | Java 11 | standard input | [
"dp",
"greedy",
"implementation",
"sortings",
"brute force"
] | 8a6953a226abef41a44963c9b4998a25 | The first line contains the integer $$$t$$$ ($$$1 \le t \le 1000$$$) — the number of test cases. The first line of each test case contains two integers $$$n$$$ and $$$x$$$ ($$$1 \le n \le 10^5; 1 \le x \le 10^9$$$) — the number of programmers and the restriction of team skill respectively. The second line of each test ... | 1,400 | For each test case print one integer — the maximum number of teams that you can assemble. | standard output | |
PASSED | a42855a51ef735d910a0d27903f9dcbd | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes | import java.util.*;
import java.io.*;
public class Main {
static class Scan {
private byte[] buf=new byte[1024];
private int index;
private InputStream in;
private int total;
public Scan()
{
in=System.in;
}
public int scan()throws IOExcepti... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | 3e9a19014ec27bdc9efb0c44cf1aa70d | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author EigenFunk
*/
public class Main {
public static void main(String[] args) {
InputStream... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | 0f9dede44a45af4b9e822b85227402ea | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes |
import java.io.*;
import java.math.BigInteger;
import java.util.*;
public class Main {
static long sx = 0, sy = 0, m = (long) (1e9 + 7);
static ArrayList<Integer>[] a;
static int[][] dp;
static long[] farr;
static boolean b = true;
// static HashMap<Long, Integer> hm = new HashMap<>();
static TreeMap<Intege... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | 08ccdf20daf5cabb157940a6fcc91130 | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes | import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Built using CHelper plug-in
* Actual solution is at the top
*
* @author Kraken7
*/
public class Main {
public static void main(String[] args) {
InputStream inputS... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | cbddc0eb038dc56f2d8a30714f3d63ef | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes | //package codeforces;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.DataInputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.StringTokenizer;
import j... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | 08e957f29c2da3e3ca636bc64fb1baaa | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes | import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;
import java.util.stream.Collectors;
/**
* <p></p>
*
* @author: xty
* @create: 2020-02-23 13:32
**/
public class Main {
public static void main(String[] args) {
int n;
Scanner sca... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | 30833c48189e423b24a662f7352a8073 | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes | import java.io.IOException;
import java.io.InputStream;
import java.util.*;
public class devesh08
{
public static void main(String args[])throws Exception
{
FastReader in=new FastReader(System.in);
int t=in.nextInt(),i,j;
StringBuilder sb=new StringBuilder();
start:while(t-->0)
{
long n=in.nextLong(),a=0;
long x=in... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | 8c5b14bb6d5b25afadbb45b502f1101a | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes | import javax.print.DocFlavor;
import java.io.*;
import java.util.*;
public class Main implements Runnable {
static boolean use_n_tests = true;
static int stack_size = 1 << 27;
void solve(FastScanner in, PrintWriter out, int testNumber) {
int n = in.nextInt();
int x = in.nextInt();
... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | 179e7a6594c48e7885b39ac244271b8d | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes | import java.io.*;
import java.util.*;
import java.lang.*;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int t = input.nextInt();
int max, min;
for (int i = 0; i < t; i++) {
int n = input.nextInt();
int x = input.nextInt();
int y = input.... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | bc9da110f44dc22db6924e5148b5eebe | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes |
import java.io.*;
import java.util.Arrays;
import java.util.Scanner;
import java.util.StringTokenizer;
public class b
{
public static void print(String str,int val){
System.out.println(str+" "+val);
}
public long gcd(long a, long b) {
if (b==0L) return a;
return gcd(b,a%b);
}... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output | |
PASSED | 07240bf613010f5f33fb3d541b1e2955 | train_002.jsonl | 1582448700 | Nikolay has only recently started in competitive programming, but already qualified to the finals of one prestigious olympiad. There going to be $$$n$$$ participants, one of whom is Nikolay. Like any good olympiad, it consists of two rounds. Tired of the traditional rules, in which the participant who solved the larges... | 256 megabytes | import java.util.Scanner;
public class IntTree {
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int t = s.nextInt();
while(t-->0){
int n=s.nextInt();
int x=s.nextInt();
int y=s.nextInt();
int min=Math.max(1,Mat... | Java | ["1\n5 1 3", "1\n6 3 4"] | 1 second | ["1 3", "2 6"] | NoteExplanation for the first example:Suppose there were 5 participants A-E. Let's denote Nikolay as A. The the most favorable results for Nikolay could look as follows: However, the results of the Olympiad could also look like this: In the first case Nikolay would have taken first place, and in the second — third pl... | Java 11 | standard input | [
"constructive algorithms",
"implementation",
"greedy",
"math"
] | 58c887568002d947706c448e6faa0f77 | The first line contains an integer $$$t$$$ ($$$1 \le t \le 100$$$) — the number of test cases to solve. Each of the following $$$t$$$ lines contains integers $$$n$$$, $$$x$$$, $$$y$$$ ($$$1 \leq n \leq 10^9$$$, $$$1 \le x, y \le n$$$) — the number of participants in the olympiad, the place that Nikolay took in the firs... | 1,700 | Print two integers — the minimum and maximum possible overall place Nikolay could take. | standard output |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.