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
aeb344b1871afa54ff19a0bbb231d9bf
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class C { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out =new PrintWriter(System.out); int n = in.nextInt(); int m = in.nextInt(); int k = in.nextInt(); int num = (n * m) / k; int rem = (n * m) %...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
b8d507394bef10c03f6a9b1eec9f01e8
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.Scanner; public class C { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int m = in.nextInt(); int k = in.nextInt(); int num = (n * m) / k; int rem = (n * m) % k; int q = 1; int t = 0; int a = 1; int b = 1; int size = 0;// te...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
08828aac84017c03680921322c020725
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.*; import java.io.*; public class Tubes { public static void main(String[] args) throws IOException { //long t1 = System.currentTimeMillis(); Scanner keyboard = new Scanner(System.in); int n = Integer.parseInt(keyboard.next()); int m = Integer.parseInt(keyboard.next()); int k = Integer.par...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
c7ad98a98ce8b3ad854ffd0465ba9e3e
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Collection; import java.util.Locale; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws IOException { new Thread(null, new Runnab...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
ac764f7d33d41175dc2805815c15e857
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.*; import java.util.*; public class C { FastScanner in = new FastScanner(System.in); PrintWriter out = new PrintWriter(System.out); public void run() { int n = in.nextInt(), m = in.nextInt(), k = in.nextInt(); int count = 0; ArrayList<String> res = new ArrayList<String>(); StringBuild...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
9f7e927aa15097a5dfbca81b1f9cb0f7
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.ArrayList; import java.util.Scanner; public class C { final public static void main ( String[] args ) { Scanner s = new Scanner( System.in ); int n = s.nextInt(); int m = s.nextInt(); int k = s.nextInt(); int totalCells = m*n; int cellsPerTube = Math.max( 2 , totalCells/k ); Tube...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
60ca0bfcb8c6720dbc214bcdad3df2bd
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.*; public class C{ public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int l = sc.nextInt(); int r = 0; int c = 1; int total = 0; for(int j = 0; j < l; j++){ int count = 0; StringBuilder sb = new StringBuilde...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
9fe43931c564bd6db315af998eadd6cb
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.Scanner; public class main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt(); int NoT = (n * m) / k; String[] input = new String[n * m]; int Left = 1; int position = 0; for (int i = 1;...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
e4658b26050845361387cdf2159167f3
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.LinkedList; import java.util.Priorit...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
f76bba75d2c0d722ba24b6fd40e7eac7
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; import java.util.Arrays; import java.util.ArrayList; import java.util.LinkedList; import java.util.TreeMap; ...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
a6a9293bfbdd4b934d290c11a5e6d73c
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.Scanner; public class ValeraAndTubes { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, m, k, t, l, r, d, x, y, c1, c2; n = sc.nextInt(); m = sc.nextInt(); k = sc.nextInt(); t = n * m; l = n * m / k; r = (n * m) % k; d = -1; y = 1; x = 0...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
1524ffc0bdd11a8e7a408421da0207ee
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
//package codeforces; import java.io.*; import java.util.*; public class C { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); PrintWriter writer = new PrintWriter(System.out); StringTokenizer stringTokenizer; C() throws IOException { // reader = new...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
261c6949660d99ae2270eda03683fd2f
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.u...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
e7ef67c0936e4e2326860355ba0561ce
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.u...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
974d34dfdeecad00c181c94e5ee08f48
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.u...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
6dcb267c2541286bef0e7d2ff6cc45f8
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.u...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
25db238a312cff9cca48c93818fa1b9a
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; /** *...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
f6d733bd57ffeaffa5494a6344207a48
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { static boolean visited[][]; static int n, m, x, h = 0, counter = 0, k; public static void main(String[] args) throws IOException { Reader.init(System.in); n = Reader.nextInt(); m = Reader.nextInt(); visited = new...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
5f3df5e6c04e0b311a7fdcc2b3193512
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.*; import java.util.*; public class Main{ final boolean isFileIO = false; BufferedReader in; PrintWriter out; StringTokenizer st = new StringTokenizer(""); String delim = " "; public static void main(String[] args) throws IOException { Main m = new Main(); m.initIO(); m.solve()...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
2330e8566d36556d2f8da90be4d55615
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; public class ValeraAndTubes { private static boolean[][] grid; private static int i = 0, j = -1; public static void main(String[] args) throws IOException { BufferedReader...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
877a0677ac11200fa28f9825a25e35de
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.IOException; import java.io.OutputStreamWriter; import java.io.BufferedWriter; import java.io.OutputStream; import java.io.PrintWriter; import java.io.Writer; import java.io.InputStream; /** * Built using CHelper plug-in * Actual solution is at the top * @author Mahmoud Aladdin <aladdin3> */ public ...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
15f97e55b8ba0cd58261251690542281
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.*; public class round441problemc { static Scanner in = new Scanner(System.in); public static void main(String[] args) { int rowNum=in.nextInt(); int colNum=in.nextInt(); int tubeNum=in.nextInt(); int cellNum=rowNum*colNum/tubeNum; int row=1; int col=1; boolean colEnd=false; ...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
816c3586b4356be5b67f40e4ebb4544b
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.util.Scanner; import java.util.Vector; /** * Ashesh Vidyut (Drift King) * */ public class C { public static void main(String[] args) { try { BufferedR...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
d4925cb013c7e219013f98113c7b9f5a
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.*; import java.util.*; import java.math.*; //import java.util.logging.Level; //import java.util.logging.Logger; public class Main { BufferedReader read; BufferedWriter write; public static void main(String args[]) throws Exception { new Main().init("1"); } void ...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
29ce1067b8b1b99aa27914d0c4912a71
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.IOException; import java.util.Scanner; public class Main { public static int n,m,k,r; public static boolean[][]g ; public static int curr; public static int x,y; public static void main(String[]args) throws IOException{ Scanner in = new Scanner(System.in); ...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
9321f21c09f2a9eaa38400c004e89156
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.IOException; import java.util.ArrayList; import java.util.StringTokenizer; public class ValeraAndTubes { public static void main(String[] args) { MyScanner sc = new MyScanner(); int N = sc.nextInt(); in...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
a214eac99acdf62cba588dd5b167add3
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.*; import java.util.*; public final class varela_and_tubes { static BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); static FastScanner sc=new FastScanner(br); static PrintWriter out=new PrintWriter(System.out); static ArrayList<Pair>[] al; static List<Pair> list=new Arr...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
72cd885938b7354287bbd9b832504ac7
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; /** * User: Andreev Kirill * Date: 18.06.14 */ public class Pipes { FastScanner in; PrintWriter out; class FastScanner { BufferedReader br;...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
ea9237811dd2496158ca75333e9e2a24
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.Scanner; public class Main { public static int cR, cC; // current row and column public static int n, m; // number of rows and number of columns public static void main(String[] args) { Scanner sc = new Scanner(System.in); n = sc.nextInt(); // number of rows m = sc.nextInt(); ...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
5ec4a312c45d4fabb7cec3afc9db6b97
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static String n1, n2;public static long min; public static int mod = 1000000007; public static void main(String[] args)throws IOException { OutputWriter out=new OutputWriter(System.out); Reader r=new Reader(); BufferedReader br =new Buffe...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
c4eb1593ef2b62108e9f6c490e0b5fd9
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.util.*; import java.io.*; import java.awt.Point; import java.math.BigDecimal; import java.math.BigInteger; import static java.lang.Math.*; // Solution is at the bottom of code public class C implements Runnable{ final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
a38196a91c7a9f6d8f0a766d8af98714
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
//package spoj; import java.util.ArrayList; import java.util.HashMap; import java.util.Map; import java.util.Scanner; import java.util.Vector; public class Back { public static void main(String[] args) { // TODO Auto-generated method stub Scanner s=new Scanner(System.in); int r=s.nextInt(); int c=s.nextInt...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
9aa9d98b507d3369f470d016fbe95d9d
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.*; import java.util.*; public class Main { public Scanner sc; private final int[] dy = { 1, -1 }; public void run() { int n = sc.nextInt(); int m = sc.nextInt(); int k = sc.nextInt(); int x = 1, y = 1, d = 0; for (int i = 0; i < k; i++) { int cnt = 0; ArrayList<Integer> xs = new...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
e60d44fe6ca98dd2e51edaa373893281
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String []args) throws FileNotFoundException, IOException { Scanner br = new Scanner(System.in); BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out)); int n = br.nextInt(); int m = br.nextInt(); int k =...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
237fc5eb5d37a4c6e4b3c7a89f6c9ae3
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /** * * @author DELL */ public class ...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
b2bb3694fd3b8ac8a190c0ab078f7c4f
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.LinkedList; public class ValeraAndTubes { static class P { int x, y; public P(int i, int j) { x = i; y = j; } public String toString() { return x + " " + y; ...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
84303aa3159697bc70dd63766905f049
train_003.jsonl
1402241400
Valera has got a rectangle table consisting of n rows and m columns. Valera numbered the table rows starting from one, from top to bottom and the columns – starting from one, from left to right. We will represent cell that is on the intersection of row x and column y by a pair of integers (x, y).Valera wants to place e...
256 megabytes
import java.io.BufferedWriter; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Scanner; public class ValeraTubes441C { public static void main(String[] args) { Scanner br = new Scanner(System.in); int rows = br.nextInt(), cols = br.nextInt(), tubes = br.nextInt(); int[][] grid ...
Java
["3 3 3", "2 3 1"]
1 second
["3 1 1 1 2 1 3\n3 2 1 2 2 2 3\n3 3 1 3 2 3 3", "6 1 1 1 2 1 3 2 3 2 2 2 1"]
NotePicture for the first sample: Picture for the second sample:
Java 7
standard input
[ "constructive algorithms", "implementation", "dfs and similar" ]
779e73c2f5eba950a20e6af9b53a643a
The first line contains three space-separated integers n, m, k (2 ≤ n, m ≤ 300; 2 ≤ 2k ≤ n·m) — the number of rows, the number of columns and the number of tubes, correspondingly.
1,500
Print k lines. In the i-th line print the description of the i-th tube: first print integer ri (the number of tube cells), then print 2ri integers xi1, yi1, xi2, yi2, ..., xiri, yiri (the sequence of table cells). If there are multiple solutions, you can print any of them. It is guaranteed that at least one solution ex...
standard output
PASSED
53ade5dfe6ed9f6b6ae8019658a55b70
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import sun.reflect.generics.tree.Tree; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.StringTokenizer; import java.util.TreeSet; /** * Created by Anna on 28.09.2016. */ pub...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
b47c409e4b58a354d152ea7b6dc8e0fb
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.Closeable; import java.io.FileInputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
69f1a03b125d536d5bce8337c43722e2
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import java.io.*; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class D { FastScanner scanner; PrintWriter writer; class Node { int n; Node parent; List<Node> children = new ArrayList<>(); int size; Node center; ...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
219aca5c68f872456a4d6455f01ff524
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import static java.lang.Math.* ; import static java.util.Arrays.* ; import java.util.*; import java.io.*; public class D{ int N, L[], P[][]; ArrayList<Integer> [] adjList ; int [] size ; int [] centroid ; int dfs(int u , int p) { int sz = 1 ; int c = u; for(int v : adjL...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
2afcfc3e6faf63f884b76bae3cc412ac
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import java.io.*; import java.util.*; /** * * @author Sourav Kumar Paul */ public class SolveD { public static int size[],parent[],centroid[]; public static ArrayList<Integer> adj[]; public static void main(String[] args) throws IOException{ Reader in = new Reader(new InputStreamReader(System.in...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
4aa383ea43f821e96b852c95bf6fc55a
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
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.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; ...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
57f853810a9b30ec70a2e25675955ba9
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; public class Main { static BufferedReader in; static PrintWriter out; static StringTokenizer buffer; ...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
8a4aa2c729493bef42054c43be4c840d
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.Iterator; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.TreeSet; ...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
c711653a2bb033dbf824e2bd55a1bddb
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import java.util.*; import java.io.*; public class Kay_and_Snowflake { public static int n; public static ArrayList<ArrayList<Integer>> adj; public static int[] ans, id; public static TreeSet<Pair> dfs(int x) { id[x] = x; int size = 1; int max = 0; TreeSet<Pair> set = new TreeSet<Pair>(); /* DFS T...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
8a74907afa13ae2dd359b9915736bd6d
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.NoSuchElementException; public class D { private static class Task { ArrayList<Integer>[] graph; ArrayList<Integer>[] inv; ...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
5849504e93db737eceaa0e3ceb62f2ec
train_003.jsonl
1466699700
After the piece of a devilish mirror hit the Kay's eye, he is no longer interested in the beauty of the roses. Now he likes to watch snowflakes.Once upon a time, he found a huge snowflake that has a form of the tree (connected acyclic graph) consisting of n nodes. The root of tree has index 1. Kay is very interested in...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Arrays; import java.util.NoSuchElementException; public class D { private static class Task { ArrayList<Integer>[] graph; ...
Java
["7 4\n1 1 3 3 5 3\n1\n2\n3\n5"]
3 seconds
["3\n2\n3\n6"]
Note The first query asks for a centroid of the whole tree — this is node 3. If we delete node 3 the tree will split in four components, two of size 1 and two of size 2.The subtree of the second node consists of this node only, so the answer is 2.Node 3 is centroid of its own subtree.The centroids of the subtree of th...
Java 8
standard input
[ "dp", "dfs and similar", "data structures", "trees" ]
7f15864d46f09ea6f117929565ccb867
The first line of the input contains two integers n and q (2 ≤ n ≤ 300 000, 1 ≤ q ≤ 300 000) — the size of the initial tree and the number of queries respectively. The second line contains n - 1 integer p2, p3, ..., pn (1 ≤ pi ≤ n) — the indices of the parents of the nodes from 2 to n. Node 1 is a root of the tree. It'...
1,900
For each query print the index of a centroid of the corresponding subtree. If there are many suitable nodes, print any of them. It's guaranteed, that each subtree has at least one centroid.
standard output
PASSED
3cdde52f7886cbc70e6a84eb575482fa
train_003.jsonl
1442416500
You are given a string S of length n with each character being one of the first m lowercase English letters. Calculate how many different strings T of length n composed from the first m lowercase English letters exist such that the length of LCS (longest common subsequence) between S and T is n - 1.Recall that LCS of t...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ public class Ideone { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc = new Scanner(System.in); int n = ...
Java
["3 3\naaa", "3 3\naab", "1 2\na", "10 9\nabacadefgh"]
2 seconds
["6", "11", "1", "789"]
NoteFor the first sample, the 6 possible strings T are: aab, aac, aba, aca, baa, caa. For the second sample, the 11 possible strings T are: aaa, aac, aba, abb, abc, aca, acb, baa, bab, caa, cab.For the third sample, the only possible string T is b.
Java 8
standard input
[ "dp", "greedy" ]
69090abd03e01dae923194e50d528216
The first line contains two numbers n and m denoting the length of string S and number of first English lowercase characters forming the character set for strings (1 ≤ n ≤ 100 000, 2 ≤ m ≤ 26). The second line contains string S.
2,700
Print the only line containing the answer.
standard output
PASSED
75733d3b7ae5c75c4ad5eadbf49a1a1c
train_003.jsonl
1442416500
You are given a string S of length n with each character being one of the first m lowercase English letters. Calculate how many different strings T of length n composed from the first m lowercase English letters exist such that the length of LCS (longest common subsequence) between S and T is n - 1.Recall that LCS of t...
256 megabytes
import java.io.*; import java.util.Scanner; public class Main1 { static int hashi(int x, int y) { if (x == y) return -1; if (x > y) { int temp = x; x = y; y = temp; } return x * 1000 + y; } public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n, m; int id[] =...
Java
["3 3\naaa", "3 3\naab", "1 2\na", "10 9\nabacadefgh"]
2 seconds
["6", "11", "1", "789"]
NoteFor the first sample, the 6 possible strings T are: aab, aac, aba, aca, baa, caa. For the second sample, the 11 possible strings T are: aaa, aac, aba, abb, abc, aca, acb, baa, bab, caa, cab.For the third sample, the only possible string T is b.
Java 8
standard input
[ "dp", "greedy" ]
69090abd03e01dae923194e50d528216
The first line contains two numbers n and m denoting the length of string S and number of first English lowercase characters forming the character set for strings (1 ≤ n ≤ 100 000, 2 ≤ m ≤ 26). The second line contains string S.
2,700
Print the only line containing the answer.
standard output
PASSED
925d3210e1a9106a0085ec72459aa497
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.PrintWriter; import java.util.Scanner; import java.util.StringTokenizer; import java.lang.Math; public class A_razvedka { final String filename = "test"; class MyScanner { Bu...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
8ab7c411308908b90682383a0913e11e
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
//package round32; import java.io.PrintWriter; import java.util.Arrays; import java.util.Scanner; public class A { private Scanner in; private PrintWriter out; // private String INPUT = "5 10 10 20 50 60 65"; // private String INPUT = "5 1 55 30 29 31 55"; private String INPUT = ""; public void solve() { int ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
153d038bba04fc9c5b78d9395a349233
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
/* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ //package broblem2.soulution; import java.util.Arrays; import java.util.Scanner; /** * * @author Shubham */ public class cf32A { ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
45637a06ef2f587cf59921df97e3efcb
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class reconassance32A { public static void main(String[] args) { try { Scanner s=new Scanner(System.in); int n=s.nextInt(); long d=s.nextLong(); int count=0; long a[]=new long[n]; ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
4e1a6216df38415505a34c0ec05acf5d
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.util.Arrays; import java.util.Scanner; /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ /*BY:-PRASANG*/ /** * * @author Seedha */ public class Reconnaissance { sta...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
4a7ad159789ee8e2a0db171c0d0e5e46
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.util.Scanner; public class a32 { public static void main(String[] args) { try { Scanner s=new Scanner(System.in); int n,d; n=s.nextInt(); d=s.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=s.nextInt()...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
6b963c3b090136e8dcf70f85a6a2a34e
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.BufferedReader; import java.io.File; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class Mai...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
aa9cd2bc26992b16d666e3196c85d756
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.util.Scanner; public class Exploration { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner in = new Scanner(System.in); int n = in.nextInt(); int d = in.nextInt(); int[] a = new int[n]; ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
cce48e5eb1c467aa4e47d4e46415d430
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.*; import java.util.*; public class Recon { public static void main(String[] args) throws IOException { BufferedReader r = new BufferedReader(new InputStreamReader(System.in)); String[] list1 = r.readLine().split(" "); long n = Long.parseLong(list1[0]); long d = Long.parseLong(list1[1]); ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
ad73251af2a00a79eb7211d96e766b52
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.util.Scanner; public class Reconnaissance { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int d = in.nextInt(); int[] a = new int[n]; for (int i = 0; i < n; i++) { ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
dd58f616068d7f953785d063d21a6ffb
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static BufferedReader bf = new BufferedReader(new InputStreamReader(System.in)); public static int nextInt() throws Exception { int x = 0, c = bf.read(); while(c < 48 || c > 57) c = bf.read(); while(c...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
96368fbc11c2561c768c9f6d3168a94b
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class ProblemA_32 { final boolean ONLINE_JUDGE=System.getProperty("ONLINE_JUDGE")!=null; BufferedReader in; PrintWriter out; StringTokenizer tok=new StringTokenizer(""); void init() throws FileNotFoundException{ if (ONLINE_JUDGE)...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
a3b3386a6b55571da5497363d2fbd41f
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.awt.Point; import java.io.*; import java.math.BigInteger; import java.util.*; import static java.lang.Math.*; public class Solution32A { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE")!=null; BufferedReader in; PrintWriter out; StringTokenizer tok =...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
4843e7080b475b7481b1d6b4c05abec2
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StreamTokenizer; public class A { static InputStreamReader in = new InputStreamReader(System.in); static BufferedReader bf = new BufferedReader(in); static StreamTokenizer st = new StreamTokenizer(...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
315c96339ca2407ae9bcf03b5d4eefb4
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.StringTokenizer; public class Main { void solve() throws IOException { int n = nextInt(); int d = nextInt(); int[] a = new int[n]; int pares = 0; for (int i = 0; i < n;...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
f0739341e972f20b2b339d56ecde7697
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Solution { BufferedReader in; PrintWriter out; StringTokenizer st; void solve() throws IOException { int n = ni(); int d = ni(); int[] v = new int[n]; for (int i = 0; i < v.length; i++) ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
6c82accde376e7b74fdcc7b8c59a7ea3
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.util.Scanner; public class p32a { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); int d = in.nextInt(); int[] all = new int[n]; for (int i = 0; i < all.length; i++) { all[i] = in.nextInt();...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
f823e4f46abfdee99b8e264f4115851d
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.PrintWriter; import java.util.Scanner; public class Solution { public static void main(String[] args) { Scanner in = new Scanner(System.in); PrintWriter out = new PrintWriter(System.out); int n = in.nextInt(); int d = in.nextInt(); int ans = 0; int[]...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
e0361b946066de52b2fac9c3fc958618
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.io.StreamTokenizer; import java.util.Arrays; public class Main { /** * @param args * @th...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
4cde119665aa6c750a1e39c1894b002d
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.fill; import static java.util.Arrays.binarySearch; import static java.util.Arrays.sort; public class Main { public static void main(String[] args) throws IOException { new Thread(null, new Runnable() { public voi...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
9906f81bdf6368253768a21da572d6ab
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.*; import java.util.*; public class Reconnaissance { Scanner in; PrintWriter out; Reconnaissance() { in = new Scanner(System.in); out = new PrintWriter(System.out); } Reconnaissance(String o) throws FileNotFoundException { in = new Scanner(System.in); out = new PrintWriter(new File(o...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
103c01d9b3f8c56d0e3d40904746e270
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class BetaRound32_A implements Runnable { final boolean ONLINE_JUDGE = System.getProperty("ONLINE_JUDGE") != null; BufferedReader in; PrintWriter out; StringTokenizer tok = new StringTokenizer(""); void init() throws IOException { i...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
ed3559ccf5827b32364be3b6677ea424
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
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.TreeSet; public class Main { private static StreamTokenizer in; private static PrintWriter out; private static BufferedReader inB; ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
6970e6d58586510c0ec2a1b8c2eb48f7
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class A { public static void main(String[] args) { new A().process(); } public void process() { Scanner in = new Scanner(System.in); int n = in.nextInt(); int d = in.nextInt(); int[] arr = new int[n]; for (int i = 0; i < n; i++) { arr[i...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
070b3d67dc7b81715b4900dbe9f3efee
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.StringTokenizer; public class Main { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); StringTokenizer st = new StringTokenize...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
306446f1d87cd96efcd6449b1575722e
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ //package javatest1; import java.io.PrintWriter; import java.util.Scanner; import java.util.ArrayList; /** * * @author alper */ public class Main { /** * @param args the command line arguments */ ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
7e8a7eb7288e19bc140c60e2caffee74
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
//package reconnaissance; import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; /** * * @author haytham */ public class Main { public static void main(String[] args) throws FileNotFoundException, IOExcept...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
d8cc89060b9ca18eac2ac747ca3557fa
train_003.jsonl
1286002800
According to the regulations of Berland's army, a reconnaissance unit should consist of exactly two soldiers. Since these two soldiers shouldn't differ much, their heights can differ by at most d centimeters. Captain Bob has n soldiers in his detachment. Their heights are a1, a2, ..., an centimeters. Some soldiers are ...
256 megabytes
import static java.lang.Integer.*; import static java.lang.Math.*; import java.io.IOException; import java.util.Scanner; @SuppressWarnings("unused") public class round32A { public static void main(String[] args)throws IOException { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); ...
Java
["5 10\n10 20 50 60 65", "5 1\n55 30 29 31 55"]
2 seconds
["6", "6"]
null
Java 6
standard input
[ "brute force" ]
d7381f73ee29c9b89671f21cafee12e7
The first line contains two integers n and d (1 ≤ n ≤ 1000, 1 ≤ d ≤ 109) — amount of soldiers in Bob's detachment and the maximum allowed height difference respectively. The second line contains n space-separated integers — heights of all the soldiers in Bob's detachment. These numbers don't exceed 109.
800
Output one number — amount of ways to form a reconnaissance unit of two soldiers, whose height difference doesn't exceed d.
standard output
PASSED
6a7436404eb0dc797dd8fcff3be82566
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.InputStreamReader; import java.io.OutputStreamWriter; import java.lang.StringBuilder; import java.util.*; public class CF342B { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(System.in); BufferedR...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
aa8d0b00626760022030585e93ac3bd0
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.*; import java.util.*; public class Main { static BufferedReader s = new BufferedReader(new InputStreamReader(System.in)); static BufferedWriter out = new BufferedWriter(new OutputStreamWriter(System.out)); static String [] r() throws IOException { return s.readLine().split(" "); } s...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
dda1b0a55c4fa62a8953ed50addadc8d
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.IOException; import java.io.BufferedReader; import java.io.InputStreamReader; import java.io.InputStream; /** * Built using CHelper plug-in * Actual soluti...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
7ca5c90c1da216da5ee1c15dcb90ae08
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.util.Scanner; /** * * @author adhithyan-3592 * **/ public class WarOfCorp { public static void main(String[] args){ Scanner input = new Scanner(System.in); String gogol = input.next(); String pineapple = input.next(); if(!gogol.contains(pineapple)){ System.out.println("0"); }else{ ...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
da6a13daaaea2c4bb285f8be1949db24
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class B { private static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); public static void main(String[] args) throws IOException { String name = br.readLine(); String coso = br.readLi...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
703cb0191c8442c468033039a70dfdbd
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.BufferedReader; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.StringTokenizer; public class R342Div2B { public static void main(String[] args) { FastScanner in=new FastScanner(); String s=in.nextToken(); String p=in.nextToken(); int m=p.length(); ArrayList<In...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
62f62e23a28947cb666f30bbff222fc7
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
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 */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
00c70ff871ebd2e2030784b1ade02ae0
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.util.Arrays; import java.util.Scanner; public class MainB { MyScanner sc = new MyScanner(); Scanner sc2 = new Scanner(System.in); long start = System.currentTimeMillis(); long fin = System.currentTimeMillis(); final int MOD = 1000000007; int[] dx = { 1, 0, 0, -1 }; int[] dy = { 0, 1, -1, 0 }; void...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
f7ebb5adc8402ef0180a5488715e8e17
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class B_Div2_342 { public static void main(String[]arg) throws IOException { new B_Div2_342().solve(); } char[]T,P; int[]b; int n,m; public void solve()throws IOException { BufferedReader in = new BufferedR...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
f6db13e9e5f6d6f739d94ba4fb5f51f8
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Arrays; import java.util.StringTokenizer; public class B { static BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static Pri...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
4290c50d475b4a430b6caeaadf9a1817
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; public class test { public static void main(String[] args)throws IOException { // Scanner ob=new Scanner(System.in); BufferedReader ob=new BufferedReader(new InputStreamReader(System.in)); String...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
058b58a098dde2349a287e4eb9e875d4
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.util.Scanner; /** * http://codeforces.com/contest/625/problem/B */ public class B { public static void main(String[] args) { new B().doJob(); } private void doJob() { try (Scanner scanner = new Scanner(System.in)) { String string = scanner.next(); String subString = scanner.next(); int...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
b84a35803c0c51bfdcb613d59940ebbf
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
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 */ public class Main { public static void main(String[] args) { InputStream inputStream = System.in...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
5ec2ba516e936ae09091c9f7f44b2337
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.awt.Point; import java.awt.geom.Line2D; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileReader; import java.io.OutputStream; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.security.GuardedObject; im...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
ed8f2a1546105d9ad34f26f8a9a2ab3d
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.util.Scanner; public class WarOfTheCorporations { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String A= scan.next(); String B = scan.next(); A=A.replace(B,"#"); int count=0; for(int i=0;i<A.length();i++) if(A.charAt(i)=='#') count++; System.out.prin...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
48ca786f4a738995356ff2c7a19c0ba4
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.*; public class A { public static void main(String [] args) throws Exception { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String first = reader.readLine().trim(); String second = reader.readLine().trim(); int lastIndex = 0; int count = 0; while(lastIndex...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
be609face6ee93370b3ba6a023d185da
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.util.Scanner; public class WarOfCorp { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); String google = sc.nextLine(); String apple = sc.nextLine(); int index = google.indexOf(apple); int occurrence...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
e14ef51d26759422a39d1142e36098c5
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.util.Scanner; public class TaskB { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String s1 = sc.nextLine(); String s2 = sc.nextLine(); int n = 0; int i = s1.indexOf(s2); while (i != -1) { ++n; i = s1.indexOf(s2, i + s2.length()); ...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
0c34a68690f188d85c0ea9795f07a4ea
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
/** * Created by Minsu on 2016-02-07. */ import java.util.*; import java.io.*; public class Main { MyScanner sc; PrintWriter out; void sol() { sc = new MyScanner(); out = new PrintWriter(new BufferedOutputStream(System.out)); String a = sc.next(), b = sc.next(); List<I...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
50712d14014899d2fdda12420e19cee8
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.util.*; import java.io.*; public class Codeforces { static BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); static StringTokenizer st; static void newST() throws IOException {st = new StringTokenizer(in.readLine());} static int stInt() {return Integer.parseInt(st.nextToken());...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
23935a1875012cef48c71511b14e8867
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.*; import java.util.*; // Input // The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of on...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output
PASSED
c0700d8729c4008575c67b41c4905f42
train_003.jsonl
1454835900
A long time ago, in a galaxy far far away two giant IT-corporations Pineapple and Gogol continue their fierce competition. Crucial moment is just around the corner: Gogol is ready to release it's new tablet Lastus 3000.This new device is equipped with specially designed artificial intelligence (AI). Employees of Pineap...
256 megabytes
import java.io.InputStreamReader; import java.io.IOException; import java.io.BufferedReader; import java.io.OutputStream; import java.io.PrintWriter; import java.util.StringTokenizer; import java.io.InputStream; public class Main { public static void main(String[] args) { InputStream inputStream = System.i...
Java
["intellect\ntell", "google\napple", "sirisiri\nsir"]
1 second
["1", "0", "2"]
NoteIn the first sample AI's name may be replaced with "int#llect".In the second sample Gogol can just keep things as they are.In the third sample one of the new possible names of AI may be "s#ris#ri".
Java 7
standard input
[ "constructive algorithms", "greedy", "strings" ]
62a672fcaee8be282700176803c623a7
The first line of the input contains the name of AI designed by Gogol, its length doesn't exceed 100 000 characters. Second line contains the name of the phone released by Pineapple 200 years ago, its length doesn't exceed 30. Both string are non-empty and consist of only small English letters.
1,200
Print the minimum number of characters that must be replaced with "#" in order to obtain that the name of the phone doesn't occur in the name of AI as a substring.
standard output