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
c5c4d41c9fb0ef7363fc122e7167132e
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.*; public class intro{ public static void main(String[] args){ Scanner in=new Scanner(System.in); String a=in.next(); String b=in.next(); int x=a.length(); a=a.replaceAll(b,""); System.out.println((x-a.length())/b.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
28b57c73a2899c8493909d46d3d8a5cd
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 B625 { public static void main(String[] args) { Scanner scan = new Scanner(System.in); String gog = scan.nextLine(); String pin = scan.nextLine(); int hash = 0, start = 0; while (true) { int mIndex = gog.indexOf(pin, start); if (mIndex == -1) break; hash...
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
4628a6a425fff4dcfd073f515eb7f090
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.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.nio.Buffer; import java.nio.charset.Charset; import java.util.Arrays; import java.util.Scanner; public class PUTOVANJE { public static...
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
5da161a2c17d6e3fba1f7783b3307ffb
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.FileInputStream; import java.io.FileNotFoundException; import java.util.Scanner; public class WarCorporations { public static void main(String[] args) throws FileNotFoundException { Scanner sc = new Scanner(System.in); // Scanner sc = new Scanner(new FileInputStream("input.txt")); String s1 = sc.n...
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
a5bb2d40b84e3f2865decafa050e5e49
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.util.regex.Pattern; import java.util.regex.Matcher; public class WarOfTheCorporations { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String lastusName = sc.nextLine(); String pineapplePhone = sc.nextLine(); int count = 0; ...
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
685f0b43b0193d685c2227da17ed6b4a
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import java.io.*; public class B{ static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; private SpaceCharFilter filter; public InputReader(InputStream stream) { ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
b6f31c7da1bd4ad50c442378336c434d
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class B { static FastReader sc=new FastReader(); public static void main(String[] args) { int ttt =i(); outer :while (ttt-- > 0) { StringBuffer sb=new StringBuffer(""); int n=i(); ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
88129d87f3345988927af8a664605c54
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int anInt = sc.nextInt(); for (int zzz = 0; zzz < anInt; zzz++) { int len = sc.nextInt(); char[][]chars = new char[len][len]; for (int...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
c93f56e8146eb6bc62c3b5b5872f1406
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int anInt = sc.nextInt(); for (int zzz = 0; zzz < anInt; zzz++) { int len = sc.nextInt(); char[][]chars = new char[len][len]; for (int...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
5b93a6dc76442b874f9161971c4a4c90
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine(...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
8bda95e31f39d1d2603c6eb9bc3ed743
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.io.*; import java.util.*; public class B { public static void main(String[] args) throws IOException{ FastScanner sc = new FastScanner(); int yo = sc.nextInt(); while(yo-->0) { int n = sc.nextInt(); char[][] arr = new char[n][n]; for(int i = 0; i < n; i++) { String s = sc.next(); ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
2cd944b9be38c181f2870b803f3e2e8a
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class Main { public static void main(String[] args) throws IOException { br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = nextInt(); for (int...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
6c2a957454380fffaf6a34806425f303
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; public class ks { public static void main(String[] args) { Scanner no=new Scanner(System.in); int t=no.nextInt(); for(int i=0;i<t;i++){ int n=no.nextInt(); char arr[][]=new char[n][n]; int ans=0; for(int j=0;j<n;j++){ String s=no.next(); arr[j]=s.toCharArray(); ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
b2f9f2710586ff7663a3aa3a0cfd7ade
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.io.*; import java.util.*; public class B { static FastReader reader = new FastReader(); //static OutputWriter out = new OutputWriter(System.out); static void solve(char[][] arr) { int n = arr.length - 1; int up = Character.getNumericValue(arr[n-1][n]); int left = Chara...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
ebcce1f739df9590abe41226caa57cae
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1421b { public static void main(String[] args) throws IOException { int t = ri(); while (t --> 0) { int n = ri(), m[][] = new int[n][n]; for (int i = 0; i...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
7a428ee0aaab9cae009d557b64b1c070
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; public class B extends Object { public static final String ANSI_RED = "\u001B[31m"; public static final String ANSI_RESET = "\u001B[0m"; static long startTime; static long endTime; static boolean [] prime ; static int M=(int)1...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
b2516d08d910fa145591e2e45e1f0b22
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.Scanner; public class CodeForces1810 { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for(int i = 0; i<t; i++) { System.out.println(algo(sc)); } } public static String algo(Scanner sc) { int ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
d0738ad151bd241218a77ccc9016c85d
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.Scanner; public class B { public static void main(String[] args) { Scanner sc = new Scanner(System.in); for (int t = sc.nextInt(); t-- > 0;) { int n = sc.nextInt(), c = 0; char a[][] = new char[n][n]; for(int i=0;i<n;i++) a[i]=sc.next().toCharArra...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
2bbae638eee0336d145980705e8b9e5b
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
//package div2_676; import java.util.ArrayList; import java.util.Scanner; public class PuttingBricksInWall { public static void main(String[] args) { Scanner in=new Scanner(System.in); int t=in.nextInt(); while(t>0) { int n=in.nextInt(); in.nextLine(); String[] s=new String[n]; for(int i=0;...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
46cf28c325b9325b4503811af195e4ab
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import javax.swing.plaf.basic.BasicScrollPaneUI.HSBChangeListener; import java.io.*; public class A { static BufferedReader br; static PrintWriter pw; static int inf = (int) 1e9; static long mod = (long) 1e9 + 7; static ArrayList<Integer>[] graph; static int n; static char[][] a; static ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
56a3800708f028691004214dc0e4d5a5
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class First { public static void main(String[] args) throws Exception { // BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); // int t = Integer.parseInt(br.readLine()); // StringBuilder sb = new StringBuilder(); // whi...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
e0b7e211cae17650ac9ba9f03910be7a
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.Scanner; import java.awt.image.BandedSampleModel; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Array; import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class B { public...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
f3c01f7f465c20045781d836c4f11024
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.io.*; import java.util.*; import java.lang.*; public class Rextester{ public static void main(String[] args)throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); StringBuffer sb = new StringBuffer()...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
6f400a7c76120dbde8a5d09a3cc55cda
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import java.io.*; public class A{ static int[] a; public static void main(String[] args) throws IOException,NumberFormatException{ try { FastScanner sc=new FastScanner(); int t=sc.nextInt(); while(t-->0) { int n=sc.nextInt(); char a[][]=new char[n][n]; for(int i=0;i<n;i++) { ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
72424154e41bc20d60fb965039f40412
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
/** * Date: 18 Oct, 2020 * Link: https://codeforces.com/contest/1421/problem/B * * @author: Prasad Chaudhari * @linkedIn: https://www.linkedin.com/in/prasad-chaudhari-841655a6/ * @git: https://github.com/Prasad-Chaudhari */ import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; impo...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
1e67a81c781c72e48bf0ed738be91682
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; public class PuttingBricksInWall { public static void main(String[] args) throws IOException{ BufferedReader r=new BufferedReader(new InputStreamReader(System.in)); int t=Integer....
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
05cdb9c1638b3a07baf9a482b71fc635
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args){ Scanner sc = new Scanner(System.in); int t = sc.nextInt(); for ( int j=0; j<t; j++ ) { int n = sc.nextInt(); String[][] m = new String[n][n]; for ( int i=0; i<n; i++ ) { String x = sc.next(); m[i] = x.split(""); ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
41c85674e7c27aed9b87aa3fff28fc4c
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.io.*; import java.util.*; public class B181020 { public static void main(String[] args) throws IOException { // TODO Auto-generated method stub BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(br.readLine()); while(t-->0) { int n =...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
a50493e061e175ad444632c32901d4f6
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; public class S { static void print1() { System.out.println(1+" "+2); return; } static void print2() { System.out.println(2+" "+1); return; } static void print3(int n) { System.out.println((n)+" "+(n-1)); return; } static void print4(int n) { ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
e4ac064484d8c4287c4d05ccfe0618d4
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine(...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
0638f8365167c6b8a2ac7b5561d261f0
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import java.lang.*; import java.io.*; public class Main { public static void main (String[] args) throws Exception { BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw = new PrintWriter(System.out); int t = Integer.parseInt(br.readLine(...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
702427bc6e9b3fbeca68ac428e2f8d89
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.io.*; import java.util.*; public class Hackerrank { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t=sc.nextInt(); for(int i=0;i<t;i++) { int n=sc.nextInt(); String[] grid= new String[n]; sc.nextLine(); for(int j=0;j<n;j++) { grid[j]=sc.nextLine(); ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
6214cc7b8896631ab7656ad5a92bf65a
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.ArrayList; import javax.management.RuntimeErrorException; import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.StringTokenizer; import java.util.Arrays; import java.util.Random; import java.io.FileWriter; import java.io...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
cb89ef0bbcaf983a319506e6de2be3df
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.lang.*; import java.util.*; import java.io.*; // import java.io.BufferedReader; // import java.io.IOException; // import java.io.InputStreamReader; public class Main { static class FastReader { BufferedReader br; StringTokenizer st; public FastReader() ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
a8e06c9cb1db8222efefd136be645d0e
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class B { static class Coord{ int x, y; public Coord(int x, int y){ this.x = x; this.y = y; } } static boolean isValid(int x, int y, int n, boolean visited[][], char arr[][], char req...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
bf5f08fc63253858feca7cf8cbe0ba3c
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.*; import java.util.Scanner; import java.io.*; import javax.lang.model.util.ElementScanner6; import static java.lang.System.out; public class B1421 { public static void main(String args[]) { FastReader in=new FastReader(); PrintWriter pr = new PrintWriter(new Buf...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
1ac41fa02eb7504f88823ae19a9ccb92
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.util.Scanner; public class solution { public static void main(String[] args) { int testNum, gridSize; String temp; char[][] grid = new char[200][200]; Scanner scanner = new Scanner(System.in); testNum = scanner.nextInt(); for (int i = 0; i < testNum...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
0cd6e57aa42f7004888262b9249d99e7
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
//"We have two lives, and the second begins when we realize we only have one." — Confucius import java.io.BufferedReader; import java.util.*; import java.io.IOException; import java.io.InputStreamReader; import java.util.Arrays; import java.util.Random; import java.util.StringTokenizer; public class C{ public static...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
08196a2d6c44b1b6e6e7557382fff9e9
train_003.jsonl
1603011900
Pink Floyd are pulling a prank on Roger Waters. They know he doesn't like walls, he wants to be able to walk freely, so they are blocking him from exiting his room which can be seen as a grid.Roger Waters has a square grid of size $$$n\times n$$$ and he wants to traverse his grid from the upper left ($$$1,1$$$) corner ...
256 megabytes
import java.lang.reflect.Array; import java.util.*; public class Solution { public static boolean check(String x,String y,String[][] s){ int n=s.length-1; int a=s[0][1].equals(y)?1:0; int b=s[1][0].equals(y)?1:0; int c=s[n][n-1].equals(x)?1:0; int d=s[n-1][n].equals(x)?1:0; ...
Java
["3\n4\nS010\n0001\n1000\n111F\n3\nS10\n101\n01F\n5\nS0101\n00000\n01111\n11111\n0001F"]
1 second
["1\n3 4\n2\n1 2\n2 1\n0"]
NoteFor the first test case, after inverting the cell, we get the following grid:S01000011001111F
Java 11
standard input
[ "constructive algorithms", "implementation" ]
be60cca56505e4b04d24c9b4990553c7
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 50$$$). Description of the test cases follows. The first line of each test case contains one integers $$$n$$$ ($$$3 \le n \le 200$$$). The following $$$n$$$ lines of each test case contain the binary grid, s...
1,100
For each test case output on the first line an integer $$$c$$$ ($$$0 \le c \le 2$$$)  — the number of inverted cells. In $$$i$$$-th of the following $$$c$$$ lines, print the coordinates of the $$$i$$$-th cell you inverted. You may not invert the same cell twice. Note that you cannot invert cells $$$(1, 1)$$$ and $$$(n...
standard output
PASSED
1b1481e1f08c29337061afe7ee71f2e7
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in=new Scanner(System.in); int n=in.nextInt(); int a,b=0,c=0; for(int i=0;i<n;i++) { a=in.nextInt(); if(a!=b)c++; b=a; } System....
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
df4c14a7a6425ec55b0e5dfd41a26c6c
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.*; public class magnet{ public static void main(String args[]){ Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int c=1,i=0; int a[]=new int[10000000]; for( i=0;i<n;i++){ a[i]=sc.nextInt(); } for( i=0;i<n-1;i++){ ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
2875392a1643b1434bf464222673e462
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Abhi { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); int a[] = new int[n]; int group = 1; for(int i=0; i<n; i++) { a[i] = s.nextInt(); } for(int i=0; i<n-1; i++) { if(a[i] != a...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
52b4145f9cee273d157cf0be4552f65d
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Magnets { public static void main (String []args){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); String [] arr = new String [n]; int c =0; boolean changed = true; for (int i=0;i<n;i++) arr[i]=sc.next()...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
650e1c7481c12a50ec85e1af618d3929
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { int n,result = 1; Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); char m[] = new char[n]; for (int i = 0; i < m.length; i++) { m[i] = (char)s...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
3457df61dff1caaf9f1dca639c12b628
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { int n,result = 1; Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); char m[] = new char[n]; for (int i = 0; i < m.length; i++) { m[i] = (char)scann...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
0a3a3e14823c97eae2b1bf8a8ce6d88f
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.*; public class ClassA { public static void main(String args[]){ Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int count = 0; int b = 0; for(int i=0; i<n; i++){ int a = sc.nextInt(); if(a != b) count++; b = a; } System.out.println(count); } }
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
60b26ba3fe137b10cbd5cd53589509c0
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class cau344A { public static void main(String[] args) { int n; int temp[] = new int[2]; int result = 1; Scanner scanner = new Scanner(System.in); n = scanner.nextInt(); for (int i = 0; i < n ; i++) { ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
5f985a5bd0577bfd19c9e8b550a07ef4
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Problem_344A{ public static void main(String[] args) { Scanner S = new Scanner(System.in); int n = S.nextInt(); int groups = 0; String Magnet; char P0 = '3'; char[] Poles; for(int i = 0; i < n; i++){ Magnet =...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
1801231d661d7efdf536f1552483f944
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class cau344A { public static void main(String[] args) { int n; int temp[] = new int[2]; int result = 1; Scanner scanner = new Scanner(System.in); do { n = scanner.nextInt(); } while (n<1 || n> 100000); for...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
62553f87e9ac0b5e53c48d1023e3cc93
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class cau344A { public static void main(String[] args) { int n; int temp[] = new int[2]; int result = 1; Scanner scanner = new Scanner(System.in); do { n = scanner.nextInt(); } while (n<1 || n> 100000); for...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
e059d35a4750813f7735776d4449d584
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class cau344A { public static void main(String[] args) { int n; int temp[] = new int[2]; boolean flag = true; int result = 1; Scanner scanner = new Scanner(System.in); do { n = scanner.nextInt(); } while (n<1 || n ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
9d3d6ac9d3dc92677358658a359ee7ac
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Magnets { static Scanner scanner = new Scanner(System.in); public static void main(String[] args) { int n = scanner.nextInt(); scanner.nextLine(); int output = 1; String s = scanner.nextLine(); for(int i = 1; i < n; i++){ ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
6660b04d51089ae3d88ca9e77b0b1338
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Magnets { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); int n = scanner.nextInt(); scanner.nextLine(); int output = 1; String s = scanner.nextLine(); for(int i = 1; i < n; i++){ ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
ae0110d9de90577b925c9d5f68931c19
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java .util.Scanner; public class HelloWorld{ public static void main(String[] args) { Scanner sc =new Scanner(System.in); int n=sc.nextInt(); int []arr=new int[n]; for(int i=0;i<n;i++){ arr[i]=sc.nextInt(); } int count=1; for(int i=0;i<arr...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
2bda379dec369c69f7d9a3bb7fdf7af5
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Main { public static void main(String[] args) { int n,i=0,j=0,a,b,ln,my=0,ck=0; Scanner input = new Scanner(System.in); n = input.nextInt(); int arr[] = new int [100001]; for(i =0; i<n; i++){ arr[i] = input.nextInt(); ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
a5cdb856c5923bb9aa8934e7c33fa1d6
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.io.DataInputStream; import java.io.FileInputStream; import java.io.IOException; public class Main { static long MOD = (long) (1e9) + 7; static class Reader { final private int BUFFER_SIZE = 1 << 16; private DataInputStream din; private byte[] buffer; private int bufferPointer, bytesRead; publ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
0ef33e9f99b2177f86365eaec55992c0
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class Magnet { public static void main(String[] args) { Scanner input=new Scanner(System.in); int n=input.nextInt(); int j[]=new int[n]; int count=j.length; for (int i=0;i<n;i++){ j[i]=input.nextInt();} fo...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
d40d571ed1a4bed44560c14e16f37be4
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
/****************************************************************************** Online Java Compiler. Code, Compile, Run and Debug java program online. Write your code in this editor and press "Run" button to execute it. *****************************************************...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
3665beb684570c6b8deaea157f027c21
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.*; import java.lang.Math; public class Main{ public static void main(String [] args){ Scanner input = new Scanner(System.in); int n = input.nextInt(); int pos = 0; int neg = 0; int count = 0; for(int i=0;i<n;i++){ pos = input.nextInt(); ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
e6d5af9c784b9890fd726827fce2bf37
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Magnets { public static void main (String[] args) throws IOException { //code BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n=Integer.parseInt(br.readLi...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
3b1dcea031faeddaab527d9927d8287b
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.*; public class Main { public static void main(String[] args) { int count=1; Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int a[]=new int[n]; for(int i=0;i<n;i++) { a[i]=sc.nextInt(); } for(int i=0;i<n-1;i++) { if(a[i]!=a[i+1]) count++; ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
090a075d76bb55407fb60cd03a1f600b
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class _344A_Magnets { public static void main(String[] args) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int k=1; if (n==1){ System.out.println("1"); return; } int m1 = input.nextInt(); ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
09d19a49c93531772ea89620f7dc06a1
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class magnets { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int ar[]=new int[n]; for(int x=0;x<n;x++) ar[x]=sc.nextInt(); int check,change; if(ar[0]==1) { ...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
97b59ba8d81c5dd6c45d522aee3469ae
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.Scanner; public class P344A { public static void main(String[] args) { // TODO Auto-generated method stub Scanner sc = new Scanner(System.in); int n=sc.nextInt(); sc.nextLine(); int start=0; int grps=0; String current_str=""; String previous_str=""; for (int i=0;i<n;i++) { if...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
249c0e9e3d24b363f4be35694c2ef8bf
train_003.jsonl
1379172600
Mad scientist Mike entertains himself by arranging rows of dominoes. He doesn't need dominoes, though: he uses rectangular magnets instead. Each magnet has two poles, positive (a "plus") and negative (a "minus"). If two magnets are put together at a close distance, then the like poles will repel each other and the oppo...
256 megabytes
import java.util.*; public class hulk { public static void main(String[] args) { Scanner console = new Scanner(System.in); int num = console.nextInt(); int groups = 1; String start = console.next(); for (int i = 0; i < num - 1; i++) { String temp = console.next();...
Java
["6\n10\n10\n10\n01\n10\n10", "4\n01\n01\n10\n10"]
1 second
["3", "2"]
NoteThe first testcase corresponds to the figure. The testcase has three groups consisting of three, one and two magnets.The second testcase has two groups, each consisting of two magnets.
Java 11
standard input
[ "implementation" ]
6c52df7ea24671102e4c0eee19dc6bba
The first line of the input contains an integer n (1 ≤ n ≤ 100000) — the number of magnets. Then n lines follow. The i-th line (1 ≤ i ≤ n) contains either characters "01", if Mike put the i-th magnet in the "plus-minus" position, or characters "10", if Mike put the magnet in the "minus-plus" position.
800
On the single line of the output print the number of groups of magnets.
standard output
PASSED
8704a19961f33ea4c6fc74bf12bc19b0
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.*; import java.math.BigInteger; import java.util.*; public class Main { static long sx = 0, sy = 0, mod = (long) (1e9 + 7); static ArrayList<Integer>[] a; static long[][][] dp; static long[] fa; static long[] farr; public static PrintWriter out; static ArrayList<pair> pa = new ArrayList<>(); ...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
562bd65fc0e8d3098c090b22dd2d780a
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Objects; import java.util.Arrays; import java.util.Scanner; import java.util.Comparator; import java.util.TreeSet; /** * Built using CHelper plug-in * Actual solution is at the top */ pu...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
8c4af12694217fb7f3c334b71955e971
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Objects; import java.util.Arrays; import java.util.Scanner; import java.util.Comparator; import java.util.TreeSet; /** * Built using CHelper plug-in * Actual solution is at the top */ pu...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
66400b7ae882f25015e8164b206f124c
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.util.Arrays; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.TreeSet; import java.util.Objects; i...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
078fef2cf40a05c9b568015e30c0fc15
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.*; import java.util.*; public class Recommendations { public static void main(String[] args) throws IOException{ BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); int n = Integer.parseInt(br.readLine()); int[][] a = new int[n][2]; for (int i = 0; i < 2; i++) { StringT...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
e4b8f85cde4e8d2e85ac5543fd3b61e3
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.*; import java.util.*; import java.util.stream.Collectors; import java.util.stream.IntStream; /** * @author Nikita Gorokhov <wackloner@yandex-team.ru> */ public class A1310 { // 420 remainder: use long everywhere private final static boolean MULTIPLE_TESTS = false; private FastReader re...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
6077b2bcaf27df63b86a8c92d00a6069
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.PriorityQueue; import java.io.IOException; import java.io.InputStreamReader; import java.util.AbstractCollection; import java.util.StringTokenizer; import java.io.Bu...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
edb47d5653ff6b4f0a5081053849d91e
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.*; import java.util.*; import static java.lang.Math.*; import static java.util.Arrays.*; public class cf1310a_2 { public static void main(String[] args) throws IOException { int n = ri(), at[][] = new int[n][2]; r(); for(int i = 0; i < n; ++i) { at[i][0] = ni();...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
4eba09fbbfe0426b2acd5e6dcdad0f80
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import static java.lang.Integer.parseInt; import static java.lang.Long.parseLong; import static java.lang.System.exit; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.PriorityQueue; import java.util.StringTokenizer; public class...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
e6e8c522ff8cae12bff43a14e780d6da
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.util.*; public class Recoomendations { public static void main(String[] args) { Scanner s = new Scanner(System.in); int n = s.nextInt(); Topic[] topics = new Topic[n+1]; //Topic[] topics2 = new Topic[n+1]; int[] temp1 = new int[n]; int[] temp2 = new int[n...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
0b75f4408ad14ba0a1a0b58704ef9f4f
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.BufferedOutputStream; import java.io.Closeable; import java.io.DataInputStream; import java.io.Flushable; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.util.AbstractMap; import java.util.Arrays; import java.util.Comparator; import java.util.InputMismatch...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
2f361d0b0933ef8d02b9da47a6e08207
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.OutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; import java.io.BufferedWriter; import java.util.InputMismatchException; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.AbstractMa...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
37ca54f93769dbd274ffd959310bf2d2
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.util.*; import java.io.*; public class Main { static FastReader in=new FastReader(); static StringBuilder Sd=new StringBuilder(); static List<Integer>Gr[]; static long Mod=998244353; static Map<Integer,Integer>map=new HashMap<>(); public static void main(String [] args) { ...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
b69a7876a85edc1ff55db2555bb09fec
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.util.*; /** * Created by Acesine on 3/27/20. */ public class A { Scanner in = new Scanner(System.in); void solve() { int n = in.nextInt(); int[][] c = new int[n][2]; for (int i=0;i<n;i++) c[i][0] = in.nextInt(); for (int i=0;i<n;i++) c[i][1] = in.nextInt(); ...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
743fbf5398536d96a4a481d46f0a1532
train_003.jsonl
1582473900
VK news recommendation system daily selects interesting publications of one of $$$n$$$ disjoint categories for each user. Each publication belongs to exactly one category. For each category $$$i$$$ batch algorithm selects $$$a_i$$$ publications.The latest A/B test suggests that users are reading recommended publication...
512 megabytes
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.Reader; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; impor...
Java
["5\n3 7 9 7 8\n5 2 5 7 5", "5\n1 2 3 4 5\n1 1 1 1 1"]
2 seconds
["6", "0"]
NoteIn the first example, it is possible to find three publications of the second type, which will take 6 seconds.In the second example, all news categories contain a different number of publications.
Java 11
standard input
[ "data structures", "sortings", "greedy" ]
6bceaf308c38d234ba931c13e4f70929
The first line of input consists of single integer $$$n$$$ — the number of news categories ($$$1 \le n \le 200\,000$$$). The second line of input consists of $$$n$$$ integers $$$a_i$$$ — the number of publications of $$$i$$$-th category selected by the batch algorithm ($$$1 \le a_i \le 10^9$$$). The third line of input...
1,700
Print one integer — the minimal required time for the targeted algorithm to get rid of categories with the same size.
standard output
PASSED
7acc6e9db4c194ae4104df3f85bd820c
train_003.jsonl
1513091100
Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h2 health points and an attack power of a2. Knowing that, Vova has d...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { public static void process()throws IOException { int h1=ni(),a1=ni(),c1=ni(),cnt=0; int h2=ni(),a2=ni(); StringBuilder res=new StringBuilder(); while(h2>0){ if(h2-a1<=0){ res...
Java
["10 6 100\n17 5", "11 6 100\n12 5"]
1 second
["4\nSTRIKE\nHEAL\nSTRIKE\nSTRIKE", "2\nSTRIKE\nSTRIKE"]
NoteIn the first example Vova's character must heal before or after his first attack. Otherwise his health will drop to zero in 2 phases while he needs 3 strikes to win.In the second example no healing needed, two strikes are enough to get monster to zero health and win with 6 health left.
Java 11
standard input
[ "implementation", "greedy" ]
d497431eb37fafdf211309da8740ece6
The first line contains three integers h1, a1, c1 (1 ≤ h1, a1 ≤ 100, 2 ≤ c1 ≤ 100) — Vova's health, Vova's attack power and the healing power of a potion. The second line contains two integers h2, a2 (1 ≤ h2 ≤ 100, 1 ≤ a2 &lt; c1) — the Modcrab's health and his attack power.
1,200
In the first line print one integer n denoting the minimum number of phases required to win the battle. Then print n lines. i-th line must be equal to HEAL if Vova drinks a potion in i-th phase, or STRIKE if he attacks the Modcrab. The strategy must be valid: Vova's character must not be defeated before slaying the Mod...
standard output
PASSED
fda9abb303755d6a20cc8246a85af5b2
train_003.jsonl
1513091100
Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h2 health points and an attack power of a2. Knowing that, Vova has d...
256 megabytes
import java.util.Iterator; import java.util.Scanner; import java.util.Vector; /* * 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 MDTus */ public class CF_903B { ...
Java
["10 6 100\n17 5", "11 6 100\n12 5"]
1 second
["4\nSTRIKE\nHEAL\nSTRIKE\nSTRIKE", "2\nSTRIKE\nSTRIKE"]
NoteIn the first example Vova's character must heal before or after his first attack. Otherwise his health will drop to zero in 2 phases while he needs 3 strikes to win.In the second example no healing needed, two strikes are enough to get monster to zero health and win with 6 health left.
Java 11
standard input
[ "implementation", "greedy" ]
d497431eb37fafdf211309da8740ece6
The first line contains three integers h1, a1, c1 (1 ≤ h1, a1 ≤ 100, 2 ≤ c1 ≤ 100) — Vova's health, Vova's attack power and the healing power of a potion. The second line contains two integers h2, a2 (1 ≤ h2 ≤ 100, 1 ≤ a2 &lt; c1) — the Modcrab's health and his attack power.
1,200
In the first line print one integer n denoting the minimum number of phases required to win the battle. Then print n lines. i-th line must be equal to HEAL if Vova drinks a potion in i-th phase, or STRIKE if he attacks the Modcrab. The strategy must be valid: Vova's character must not be defeated before slaying the Mod...
standard output
PASSED
277eb301fae6203e5e2f0e838c19a907
train_003.jsonl
1513091100
Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h2 health points and an attack power of a2. Knowing that, Vova has d...
256 megabytes
import java.util.*; import java.io.*; import java.math.*; public class Main { static PrintWriter out = new PrintWriter(System.out); static Reader in = new Reader(); public static void main(String[] args) throws IOException { Main solver = new Main(); solver.solve(); out.flush(); ...
Java
["10 6 100\n17 5", "11 6 100\n12 5"]
1 second
["4\nSTRIKE\nHEAL\nSTRIKE\nSTRIKE", "2\nSTRIKE\nSTRIKE"]
NoteIn the first example Vova's character must heal before or after his first attack. Otherwise his health will drop to zero in 2 phases while he needs 3 strikes to win.In the second example no healing needed, two strikes are enough to get monster to zero health and win with 6 health left.
Java 11
standard input
[ "implementation", "greedy" ]
d497431eb37fafdf211309da8740ece6
The first line contains three integers h1, a1, c1 (1 ≤ h1, a1 ≤ 100, 2 ≤ c1 ≤ 100) — Vova's health, Vova's attack power and the healing power of a potion. The second line contains two integers h2, a2 (1 ≤ h2 ≤ 100, 1 ≤ a2 &lt; c1) — the Modcrab's health and his attack power.
1,200
In the first line print one integer n denoting the minimum number of phases required to win the battle. Then print n lines. i-th line must be equal to HEAL if Vova drinks a potion in i-th phase, or STRIKE if he attacks the Modcrab. The strategy must be valid: Vova's character must not be defeated before slaying the Mod...
standard output
PASSED
a6492f741d22e8e07039a3a13015e8bf
train_003.jsonl
1513091100
Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h2 health points and an attack power of a2. Knowing that, Vova has d...
256 megabytes
import java.math.BigInteger; import java.util.*; import java.io.*; public class solution { public static void merge(int arr[], int l, int m, int r) { // Find sizes of two subarrays to be merged int n1 = m - l + 1; int n2 = r - m; /* Create temp arrays */ int L[] = new int[n...
Java
["10 6 100\n17 5", "11 6 100\n12 5"]
1 second
["4\nSTRIKE\nHEAL\nSTRIKE\nSTRIKE", "2\nSTRIKE\nSTRIKE"]
NoteIn the first example Vova's character must heal before or after his first attack. Otherwise his health will drop to zero in 2 phases while he needs 3 strikes to win.In the second example no healing needed, two strikes are enough to get monster to zero health and win with 6 health left.
Java 11
standard input
[ "implementation", "greedy" ]
d497431eb37fafdf211309da8740ece6
The first line contains three integers h1, a1, c1 (1 ≤ h1, a1 ≤ 100, 2 ≤ c1 ≤ 100) — Vova's health, Vova's attack power and the healing power of a potion. The second line contains two integers h2, a2 (1 ≤ h2 ≤ 100, 1 ≤ a2 &lt; c1) — the Modcrab's health and his attack power.
1,200
In the first line print one integer n denoting the minimum number of phases required to win the battle. Then print n lines. i-th line must be equal to HEAL if Vova drinks a potion in i-th phase, or STRIKE if he attacks the Modcrab. The strategy must be valid: Vova's character must not be defeated before slaying the Mod...
standard output
PASSED
8d03c896067f4226df7432d16976ef14
train_003.jsonl
1513091100
Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h2 health points and an attack power of a2. Knowing that, Vova has d...
256 megabytes
import java.util.*; public class Solution{ static int count = 0; static void solve(int ah,int aat,int apo,int bh,int ba) { while(bh>0) { if(aat>=bh) { count++; break; } if(ah<=ba) { ah+=apo; count++; ah-=ba; }else{ bh-=aat; ah-=ba; count++; } } } stat...
Java
["10 6 100\n17 5", "11 6 100\n12 5"]
1 second
["4\nSTRIKE\nHEAL\nSTRIKE\nSTRIKE", "2\nSTRIKE\nSTRIKE"]
NoteIn the first example Vova's character must heal before or after his first attack. Otherwise his health will drop to zero in 2 phases while he needs 3 strikes to win.In the second example no healing needed, two strikes are enough to get monster to zero health and win with 6 health left.
Java 11
standard input
[ "implementation", "greedy" ]
d497431eb37fafdf211309da8740ece6
The first line contains three integers h1, a1, c1 (1 ≤ h1, a1 ≤ 100, 2 ≤ c1 ≤ 100) — Vova's health, Vova's attack power and the healing power of a potion. The second line contains two integers h2, a2 (1 ≤ h2 ≤ 100, 1 ≤ a2 &lt; c1) — the Modcrab's health and his attack power.
1,200
In the first line print one integer n denoting the minimum number of phases required to win the battle. Then print n lines. i-th line must be equal to HEAL if Vova drinks a potion in i-th phase, or STRIKE if he attacks the Modcrab. The strategy must be valid: Vova's character must not be defeated before slaying the Mod...
standard output
PASSED
006f3f148f15e73583c85b5f84bd4ed0
train_003.jsonl
1513091100
Vova is again playing some computer game, now an RPG. In the game Vova's character received a quest: to slay the fearsome monster called Modcrab.After two hours of playing the game Vova has tracked the monster and analyzed its tactics. The Modcrab has h2 health points and an attack power of a2. Knowing that, Vova has d...
256 megabytes
import java.io.BufferedReader; import java.io.FileReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import ja...
Java
["10 6 100\n17 5", "11 6 100\n12 5"]
1 second
["4\nSTRIKE\nHEAL\nSTRIKE\nSTRIKE", "2\nSTRIKE\nSTRIKE"]
NoteIn the first example Vova's character must heal before or after his first attack. Otherwise his health will drop to zero in 2 phases while he needs 3 strikes to win.In the second example no healing needed, two strikes are enough to get monster to zero health and win with 6 health left.
Java 11
standard input
[ "implementation", "greedy" ]
d497431eb37fafdf211309da8740ece6
The first line contains three integers h1, a1, c1 (1 ≤ h1, a1 ≤ 100, 2 ≤ c1 ≤ 100) — Vova's health, Vova's attack power and the healing power of a potion. The second line contains two integers h2, a2 (1 ≤ h2 ≤ 100, 1 ≤ a2 &lt; c1) — the Modcrab's health and his attack power.
1,200
In the first line print one integer n denoting the minimum number of phases required to win the battle. Then print n lines. i-th line must be equal to HEAL if Vova drinks a potion in i-th phase, or STRIKE if he attacks the Modcrab. The strategy must be valid: Vova's character must not be defeated before slaying the Mod...
standard output
PASSED
d39715ef0df526b073e0d041d597e0a5
train_003.jsonl
1543163700
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.During his ride, Arkady woke up several times ...
256 megabytes
import java.io.*; import java.util.*; import java.text.*; import java.math.*; import java.util.regex.*; import java.awt.Point; public class TryB { static class InputReader { private final InputStream stream; private final byte[] buf = new byte[8192]; private int curChar, snumChars; public Inpu...
Java
["3\n3 1 4 6\n2 1 4\n5 10 5 6 4 1", "5\n1 1\n10 10 9 8 7 100 5 4 3 99 1\n5 1 2 3 4 5\n5 4 1 3 2 5\n4 10 1 5 3"]
1 second
["1 4", "1"]
NoteConsider the first example. Arkady woke up three times. The first time he saw a stop with lines $$$1$$$, $$$4$$$, $$$6$$$. The second time he saw a stop with lines $$$1$$$, $$$4$$$. The third time he saw a stop with lines $$$10$$$, $$$5$$$, $$$6$$$, $$$4$$$ and $$$1$$$. He can be in a tram of one of two lines: $$$1...
Java 8
standard input
[ "implementation" ]
16c54cf7d8b484b5e22a7d391fdc5cd3
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of stops Arkady saw. The next $$$n$$$ lines describe the stops. Each of them starts with a single integer $$$r$$$ ($$$1 \le r \le 100$$$) — the number of tram lines that stop there. $$$r$$$ distinct integers follow, each one between $...
800
Print all tram lines that Arkady could be in, in arbitrary order.
standard output
PASSED
3023773f9d6bc01fbea18aba15077e0b
train_003.jsonl
1543163700
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.During his ride, Arkady woke up several times ...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.HashSet; import java.util.Scanner; /** * * @author Jakub */ public class ProblemA { /** * @param args the command line arguments */ public static void main(String[] args) throws IOExcepti...
Java
["3\n3 1 4 6\n2 1 4\n5 10 5 6 4 1", "5\n1 1\n10 10 9 8 7 100 5 4 3 99 1\n5 1 2 3 4 5\n5 4 1 3 2 5\n4 10 1 5 3"]
1 second
["1 4", "1"]
NoteConsider the first example. Arkady woke up three times. The first time he saw a stop with lines $$$1$$$, $$$4$$$, $$$6$$$. The second time he saw a stop with lines $$$1$$$, $$$4$$$. The third time he saw a stop with lines $$$10$$$, $$$5$$$, $$$6$$$, $$$4$$$ and $$$1$$$. He can be in a tram of one of two lines: $$$1...
Java 8
standard input
[ "implementation" ]
16c54cf7d8b484b5e22a7d391fdc5cd3
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of stops Arkady saw. The next $$$n$$$ lines describe the stops. Each of them starts with a single integer $$$r$$$ ($$$1 \le r \le 100$$$) — the number of tram lines that stop there. $$$r$$$ distinct integers follow, each one between $...
800
Print all tram lines that Arkady could be in, in arbitrary order.
standard output
PASSED
57a000c46075c6df663199c134c536f4
train_003.jsonl
1543163700
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.During his ride, Arkady woke up several times ...
256 megabytes
import java.io.*; import java.util.*; public class Main { public static void main(String[] args) throws Exception { BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); int t = Integer.parseInt(in.readLine()); HashSet<Integer>[] sets = new HashSet[t]; for (int ...
Java
["3\n3 1 4 6\n2 1 4\n5 10 5 6 4 1", "5\n1 1\n10 10 9 8 7 100 5 4 3 99 1\n5 1 2 3 4 5\n5 4 1 3 2 5\n4 10 1 5 3"]
1 second
["1 4", "1"]
NoteConsider the first example. Arkady woke up three times. The first time he saw a stop with lines $$$1$$$, $$$4$$$, $$$6$$$. The second time he saw a stop with lines $$$1$$$, $$$4$$$. The third time he saw a stop with lines $$$10$$$, $$$5$$$, $$$6$$$, $$$4$$$ and $$$1$$$. He can be in a tram of one of two lines: $$$1...
Java 8
standard input
[ "implementation" ]
16c54cf7d8b484b5e22a7d391fdc5cd3
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of stops Arkady saw. The next $$$n$$$ lines describe the stops. Each of them starts with a single integer $$$r$$$ ($$$1 \le r \le 100$$$) — the number of tram lines that stop there. $$$r$$$ distinct integers follow, each one between $...
800
Print all tram lines that Arkady could be in, in arbitrary order.
standard output
PASSED
851055f795ccf8123bcf9c3f6920b6a9
train_003.jsonl
1543163700
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.During his ride, Arkady woke up several times ...
256 megabytes
//Author: Mo Abjal, MJP Rohilkhand University Bareilly, UP, India 2018. /////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////********************////////////////////////////////////////////// ////////////////////////////////...
Java
["3\n3 1 4 6\n2 1 4\n5 10 5 6 4 1", "5\n1 1\n10 10 9 8 7 100 5 4 3 99 1\n5 1 2 3 4 5\n5 4 1 3 2 5\n4 10 1 5 3"]
1 second
["1 4", "1"]
NoteConsider the first example. Arkady woke up three times. The first time he saw a stop with lines $$$1$$$, $$$4$$$, $$$6$$$. The second time he saw a stop with lines $$$1$$$, $$$4$$$. The third time he saw a stop with lines $$$10$$$, $$$5$$$, $$$6$$$, $$$4$$$ and $$$1$$$. He can be in a tram of one of two lines: $$$1...
Java 8
standard input
[ "implementation" ]
16c54cf7d8b484b5e22a7d391fdc5cd3
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of stops Arkady saw. The next $$$n$$$ lines describe the stops. Each of them starts with a single integer $$$r$$$ ($$$1 \le r \le 100$$$) — the number of tram lines that stop there. $$$r$$$ distinct integers follow, each one between $...
800
Print all tram lines that Arkady could be in, in arbitrary order.
standard output
PASSED
07054c06a49944a9e243a3d92b54440f
train_003.jsonl
1543163700
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.During his ride, Arkady woke up several times ...
256 megabytes
import java.util.*; public class Solution { public static void main(String args[]) { Scanner sc=new Scanner(System.in); int t=sc.nextInt(); List<Integer> list1=new ArrayList<>(); for(int i=0;i<t;i++) ...
Java
["3\n3 1 4 6\n2 1 4\n5 10 5 6 4 1", "5\n1 1\n10 10 9 8 7 100 5 4 3 99 1\n5 1 2 3 4 5\n5 4 1 3 2 5\n4 10 1 5 3"]
1 second
["1 4", "1"]
NoteConsider the first example. Arkady woke up three times. The first time he saw a stop with lines $$$1$$$, $$$4$$$, $$$6$$$. The second time he saw a stop with lines $$$1$$$, $$$4$$$. The third time he saw a stop with lines $$$10$$$, $$$5$$$, $$$6$$$, $$$4$$$ and $$$1$$$. He can be in a tram of one of two lines: $$$1...
Java 8
standard input
[ "implementation" ]
16c54cf7d8b484b5e22a7d391fdc5cd3
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of stops Arkady saw. The next $$$n$$$ lines describe the stops. Each of them starts with a single integer $$$r$$$ ($$$1 \le r \le 100$$$) — the number of tram lines that stop there. $$$r$$$ distinct integers follow, each one between $...
800
Print all tram lines that Arkady could be in, in arbitrary order.
standard output
PASSED
d4baf6c75ef590f6f66da3da5c78c35f
train_003.jsonl
1543163700
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.During his ride, Arkady woke up several times ...
256 megabytes
import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.Arrays; import java.util.HashSet; import java.util.InputMismatchException; import java.util.Set; public class A { InputStream is; PrintWriter out; String INPUT = ""; void solv...
Java
["3\n3 1 4 6\n2 1 4\n5 10 5 6 4 1", "5\n1 1\n10 10 9 8 7 100 5 4 3 99 1\n5 1 2 3 4 5\n5 4 1 3 2 5\n4 10 1 5 3"]
1 second
["1 4", "1"]
NoteConsider the first example. Arkady woke up three times. The first time he saw a stop with lines $$$1$$$, $$$4$$$, $$$6$$$. The second time he saw a stop with lines $$$1$$$, $$$4$$$. The third time he saw a stop with lines $$$10$$$, $$$5$$$, $$$6$$$, $$$4$$$ and $$$1$$$. He can be in a tram of one of two lines: $$$1...
Java 8
standard input
[ "implementation" ]
16c54cf7d8b484b5e22a7d391fdc5cd3
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of stops Arkady saw. The next $$$n$$$ lines describe the stops. Each of them starts with a single integer $$$r$$$ ($$$1 \le r \le 100$$$) — the number of tram lines that stop there. $$$r$$$ distinct integers follow, each one between $...
800
Print all tram lines that Arkady could be in, in arbitrary order.
standard output
PASSED
8b6db7827804d07e91877b5351e61d84
train_003.jsonl
1543163700
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.During his ride, Arkady woke up several times ...
256 megabytes
import java.util.Scanner; public class FirstStep { public static void main(String args[]) { Scanner input = new Scanner(System.in); int n = input.nextInt(); int []count = new int[101]; int max = 0; for(int i=0;i<n;i+=1){ int r = input.nextInt(); for (int j=0;j<r;j++){ int t = input.nextInt(); ...
Java
["3\n3 1 4 6\n2 1 4\n5 10 5 6 4 1", "5\n1 1\n10 10 9 8 7 100 5 4 3 99 1\n5 1 2 3 4 5\n5 4 1 3 2 5\n4 10 1 5 3"]
1 second
["1 4", "1"]
NoteConsider the first example. Arkady woke up three times. The first time he saw a stop with lines $$$1$$$, $$$4$$$, $$$6$$$. The second time he saw a stop with lines $$$1$$$, $$$4$$$. The third time he saw a stop with lines $$$10$$$, $$$5$$$, $$$6$$$, $$$4$$$ and $$$1$$$. He can be in a tram of one of two lines: $$$1...
Java 8
standard input
[ "implementation" ]
16c54cf7d8b484b5e22a7d391fdc5cd3
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of stops Arkady saw. The next $$$n$$$ lines describe the stops. Each of them starts with a single integer $$$r$$$ ($$$1 \le r \le 100$$$) — the number of tram lines that stop there. $$$r$$$ distinct integers follow, each one between $...
800
Print all tram lines that Arkady could be in, in arbitrary order.
standard output
PASSED
7b8f2d7c6feaece3edf4f4d2e914ddc4
train_003.jsonl
1543163700
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.During his ride, Arkady woke up several times ...
256 megabytes
import java.util.*; public class A { public static void main(String[] args) { Scanner in = new Scanner(System.in); int n = in.nextInt(); HashSet<Integer> ms = new HashSet<Integer>(100); for (int i = 0; i<=100; i++) { ms.add(i); } for (int i=0; i...
Java
["3\n3 1 4 6\n2 1 4\n5 10 5 6 4 1", "5\n1 1\n10 10 9 8 7 100 5 4 3 99 1\n5 1 2 3 4 5\n5 4 1 3 2 5\n4 10 1 5 3"]
1 second
["1 4", "1"]
NoteConsider the first example. Arkady woke up three times. The first time he saw a stop with lines $$$1$$$, $$$4$$$, $$$6$$$. The second time he saw a stop with lines $$$1$$$, $$$4$$$. The third time he saw a stop with lines $$$10$$$, $$$5$$$, $$$6$$$, $$$4$$$ and $$$1$$$. He can be in a tram of one of two lines: $$$1...
Java 8
standard input
[ "implementation" ]
16c54cf7d8b484b5e22a7d391fdc5cd3
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of stops Arkady saw. The next $$$n$$$ lines describe the stops. Each of them starts with a single integer $$$r$$$ ($$$1 \le r \le 100$$$) — the number of tram lines that stop there. $$$r$$$ distinct integers follow, each one between $...
800
Print all tram lines that Arkady could be in, in arbitrary order.
standard output
PASSED
a40e9f483b244d2cfc791213ecef4dbd
train_003.jsonl
1543163700
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.During his ride, Arkady woke up several times ...
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[] stops = new int[101]; StringBuilder sb = new StringBuilder(); for(int i=0;i<n;i++){ int cant = sc.nextInt(); ...
Java
["3\n3 1 4 6\n2 1 4\n5 10 5 6 4 1", "5\n1 1\n10 10 9 8 7 100 5 4 3 99 1\n5 1 2 3 4 5\n5 4 1 3 2 5\n4 10 1 5 3"]
1 second
["1 4", "1"]
NoteConsider the first example. Arkady woke up three times. The first time he saw a stop with lines $$$1$$$, $$$4$$$, $$$6$$$. The second time he saw a stop with lines $$$1$$$, $$$4$$$. The third time he saw a stop with lines $$$10$$$, $$$5$$$, $$$6$$$, $$$4$$$ and $$$1$$$. He can be in a tram of one of two lines: $$$1...
Java 8
standard input
[ "implementation" ]
16c54cf7d8b484b5e22a7d391fdc5cd3
The first line contains a single integer $$$n$$$ ($$$2 \le n \le 100$$$) — the number of stops Arkady saw. The next $$$n$$$ lines describe the stops. Each of them starts with a single integer $$$r$$$ ($$$1 \le r \le 100$$$) — the number of tram lines that stop there. $$$r$$$ distinct integers follow, each one between $...
800
Print all tram lines that Arkady could be in, in arbitrary order.
standard output
PASSED
a224c58984c3dcd9f2247eac5d7583c4
train_003.jsonl
1503592500
You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence also will be sorted in increasing order.Sorting integers in a subsequence is a...
256 megabytes
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; import java.util.InputMismatchException; public class Solutio...
Java
["6\n3 2 1 6 5 4", "6\n83 -75 -49 11 37 62"]
1 second
["4\n2 1 3\n1 2\n2 4 6\n1 5", "1\n6 1 2 3 4 5 6"]
NoteIn the first sample output:After sorting the first subsequence we will get sequence 1 2 3 6 5 4.Sorting the second subsequence changes nothing.After sorting the third subsequence we will get sequence 1 2 3 4 5 6.Sorting the last subsequence changes nothing.
Java 8
standard input
[ "dfs and similar", "math" ]
159365b2f037647fbaa656905e6f5252
The first line of input data contains integer n (1 ≤ n ≤ 105) — the length of the sequence. The second line of input data contains n different integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — the elements of the sequence. It is guaranteed that all elements of the sequence are distinct.
1,400
In the first line print the maximum number of subsequences k, which the original sequence can be split into while fulfilling the requirements. In the next k lines print the description of subsequences in the following format: the number of elements in subsequence ci (0 &lt; ci ≤ n), then ci integers l1, l2, ..., lci (1...
standard output
PASSED
a8e9e0e71590580a6f95923f9e2af6f8
train_003.jsonl
1503592500
You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence also will be sorted in increasing order.Sorting integers in a subsequence is a...
256 megabytes
import java.io.IOException; import java.io.InputStream; import java.io.PrintWriter; import java.util.*; public class Main { public static void main(String[] args) { InputReader in = new InputReader(); PrintWriter out = new PrintWriter(System.out); final long start = System.currentTimeMillis(); new Task1()...
Java
["6\n3 2 1 6 5 4", "6\n83 -75 -49 11 37 62"]
1 second
["4\n2 1 3\n1 2\n2 4 6\n1 5", "1\n6 1 2 3 4 5 6"]
NoteIn the first sample output:After sorting the first subsequence we will get sequence 1 2 3 6 5 4.Sorting the second subsequence changes nothing.After sorting the third subsequence we will get sequence 1 2 3 4 5 6.Sorting the last subsequence changes nothing.
Java 8
standard input
[ "dfs and similar", "math" ]
159365b2f037647fbaa656905e6f5252
The first line of input data contains integer n (1 ≤ n ≤ 105) — the length of the sequence. The second line of input data contains n different integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — the elements of the sequence. It is guaranteed that all elements of the sequence are distinct.
1,400
In the first line print the maximum number of subsequences k, which the original sequence can be split into while fulfilling the requirements. In the next k lines print the description of subsequences in the following format: the number of elements in subsequence ci (0 &lt; ci ≤ n), then ci integers l1, l2, ..., lci (1...
standard output
PASSED
25721fc4ab5392105272a0f462470fb2
train_003.jsonl
1503592500
You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence also will be sorted in increasing order.Sorting integers in a subsequence is a...
256 megabytes
import java.util.*; public class j2 { static ArrayList<Integer> tmp; public static void main(String args[]) { Scanner sc=new Scanner(System.in); int n=sc.nextInt(); int arr[]=new int[n]; HashMap<Integer,Integer> mp = new HashMap<>(); i...
Java
["6\n3 2 1 6 5 4", "6\n83 -75 -49 11 37 62"]
1 second
["4\n2 1 3\n1 2\n2 4 6\n1 5", "1\n6 1 2 3 4 5 6"]
NoteIn the first sample output:After sorting the first subsequence we will get sequence 1 2 3 6 5 4.Sorting the second subsequence changes nothing.After sorting the third subsequence we will get sequence 1 2 3 4 5 6.Sorting the last subsequence changes nothing.
Java 8
standard input
[ "dfs and similar", "math" ]
159365b2f037647fbaa656905e6f5252
The first line of input data contains integer n (1 ≤ n ≤ 105) — the length of the sequence. The second line of input data contains n different integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — the elements of the sequence. It is guaranteed that all elements of the sequence are distinct.
1,400
In the first line print the maximum number of subsequences k, which the original sequence can be split into while fulfilling the requirements. In the next k lines print the description of subsequences in the following format: the number of elements in subsequence ci (0 &lt; ci ≤ n), then ci integers l1, l2, ..., lci (1...
standard output
PASSED
f3aa9d338d2550ed68a6111630f32f4a
train_003.jsonl
1503592500
You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence also will be sorted in increasing order.Sorting integers in a subsequence is a...
256 megabytes
/** * All cobbled together from old pieces of code. Took way too long. * If it's even correct. */ import java.io.*; import java.util.*; import java.util.stream.*; public class Subsequences { public static void main(String [] av) { Scanner s = new Scanner(); int n = s.nextInt(); List<Int...
Java
["6\n3 2 1 6 5 4", "6\n83 -75 -49 11 37 62"]
1 second
["4\n2 1 3\n1 2\n2 4 6\n1 5", "1\n6 1 2 3 4 5 6"]
NoteIn the first sample output:After sorting the first subsequence we will get sequence 1 2 3 6 5 4.Sorting the second subsequence changes nothing.After sorting the third subsequence we will get sequence 1 2 3 4 5 6.Sorting the last subsequence changes nothing.
Java 8
standard input
[ "dfs and similar", "math" ]
159365b2f037647fbaa656905e6f5252
The first line of input data contains integer n (1 ≤ n ≤ 105) — the length of the sequence. The second line of input data contains n different integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — the elements of the sequence. It is guaranteed that all elements of the sequence are distinct.
1,400
In the first line print the maximum number of subsequences k, which the original sequence can be split into while fulfilling the requirements. In the next k lines print the description of subsequences in the following format: the number of elements in subsequence ci (0 &lt; ci ≤ n), then ci integers l1, l2, ..., lci (1...
standard output
PASSED
b114b502d2189922f70009d42ea24c19
train_003.jsonl
1503592500
You are given a sequence a1, a2, ..., an consisting of different integers. It is required to split this sequence into the maximum number of subsequences such that after sorting integers in each of them in increasing order, the total sequence also will be sorted in increasing order.Sorting integers in a subsequence is a...
256 megabytes
import java.io.*; import java.nio.ByteBuffer; import java.util.*; /** * Created by imahmoud on 5/13/17. */ public class C { static class Writer { private OutputStream out; public Writer(){ out = new BufferedOutputStream(System.out); } public void println() throws IO...
Java
["6\n3 2 1 6 5 4", "6\n83 -75 -49 11 37 62"]
1 second
["4\n2 1 3\n1 2\n2 4 6\n1 5", "1\n6 1 2 3 4 5 6"]
NoteIn the first sample output:After sorting the first subsequence we will get sequence 1 2 3 6 5 4.Sorting the second subsequence changes nothing.After sorting the third subsequence we will get sequence 1 2 3 4 5 6.Sorting the last subsequence changes nothing.
Java 8
standard input
[ "dfs and similar", "math" ]
159365b2f037647fbaa656905e6f5252
The first line of input data contains integer n (1 ≤ n ≤ 105) — the length of the sequence. The second line of input data contains n different integers a1, a2, ..., an ( - 109 ≤ ai ≤ 109) — the elements of the sequence. It is guaranteed that all elements of the sequence are distinct.
1,400
In the first line print the maximum number of subsequences k, which the original sequence can be split into while fulfilling the requirements. In the next k lines print the description of subsequences in the following format: the number of elements in subsequence ci (0 &lt; ci ≤ n), then ci integers l1, l2, ..., lci (1...
standard output